Friday, 23 August 2013

Performing method on another UIViewController

Performing method on another UIViewController

I use this method to set text on a label in SViewController, from
FViewController:
SViewController *vc = [self.storyboard
instantiateViewControllerWithIdentifier:@"SViewController"];
[vc setTextForLabel:[NSNumber numberWithInt:1];];
[self.navigationController pushViewController:vc animated:YES];
The setTextForLabel method:
-(void) setTextForLabel: (NSNumber *)text{
textLabel = [[UILabel alloc] init];
[textLabel setText:[NSString stringWithFormat:@"%@",[text stringValue]]];
NSLog(@"The text is %@", textLabel.text);
}
textLabel is @property (nonatomic, retain) IBOutlet UILabel *textLabel; in
h. file, an is connected to its outlet in Storyboard.
Now in console I see "The text is 1", but the UI is not showing anything!
What am I doing wrong?
Tnx!

No comments:

Post a Comment