i just learn how to change switch between views with push and pop. now, to my second view i add a label witch i wand to change her value every time my second view is push. i add the label, connect her to my file owner's and i use viewdidload to change her value. when i entered to my second view nothing is happed. but when i use viewdidapper all work perfect(but it take a second until the label value is update).
my code is: mysecondviewcontroller.h:
@interface SecondViewController : UIViewController
{
IBOutlet UILabel *textLabel;
NSString *label;
}
@property (copy) NSString *label;
@end
mysecondviewcontroller.m(ofcourse i synthesize label):
-(void)viewDidAppear:(BOOL)animated
{
textLabel.text = label;
NSLog(@"viewdidapper2");
}
- (void)viewDidLoad
{
textLabel.text = label;
[super viewDidLoad];
NSLog(@"viewdidload2");
// Do any additional setup after loading the view from its nib.
}
my firstviewcontroller.m(IBAction):
- (IBAction)pushViewController:(id)sender
{
static int count = 1;
SecondViewController *secondVieController = [[SecondViewController alloc] init];
[self.navigationController pushViewController:secondVieController animated:YES];
secondVieController.title = @"second";
secondVieController.label = [NSString stringWithFormat:@"number: %d", count];
count++;
}
what is the problem in my viewdidload?
thanks!