tags:

views:

116

answers:

3

I have two UIViewController classes in my project... Each Viewcontroller has uilabel... When i click my firstviewcontroller button, i send data to secondviewcontroller and display that data into secondviewcontroller label....But nothing is displayed on the second label.

Can anyone help me?

Thanks in advance.....

A: 

To display information on a UILabel control you need to set its text property to some string:

NSString *myText = @"Hello";
myLabel.text = myText;
Fraser Speirs
A: 

Have you allocated your second UIViewController? When loading your second UIViewController you might need to pass that string to it so it knows what to display.

Depending on how you are setting things up you might also try refreshing the second UIViewController. There is a function viewWillAppear which will be called every time the view is being shown, you could reset your label there.

RyanJM
A: 

Remember you can only set the text in the second view controller once its view has loaded, NOT in the init method. You could pass the UILabel's text to the second view controller as a parameter to a custom init method, save the string as an attribute of the second view controller's class, and then set it as the label's text in your viewDidLoad method.

Andres Bonilla