i create i navigationController project name:autoload, then create two uiviewContorller named: second,three
i want the process is load rootView the load second in method:"viewDidLoad" then auto load three in method"viewdidload", here is the code:
rootView:
- (void)viewDidLoad {
self.title = @"first";
Second *second = [[Second alloc] init];
AutoLoadAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navigationController pushViewController:second animated:YES];
[super viewDidLoad];
}
second:
- (void)viewDidLoad {
self.title = @"second";
[super viewDidLoad];
}
now build an go the program, i can auto load to second very correct includeing the title content and also the navgation button
then i want aotoload three in second,so add the code in second method:"viewdidload"
second:
- (void)viewDidLoad {
self.title = @"second";
**Three *three = [[Three alloc] init];
AutoLoadAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navigationController pushViewController:three animated:YES];**
[super viewDidLoad];
}
finaly add the title to three:
three:
- (void)viewDidLoad {
self.title = @"three";
[super viewDidLoad];
}
then build and go, you will find that the content is right "three" but the title is wrong "second", it should be "three" and you will also find the navgation button is wrong
what's wrong with my that,what i should do to implement the program of autoload to three?
note:
i try that : if i add a button in second and move the code
Three *three = [[Three alloc] init];
AutoLoadAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navigationController pushViewController:three animated:YES];
to the ibaction ,it will be work correct, but i want it load automaticly