Reputation: 601
I know that viewWillAppear is not called on pop/push views, but I really need that method. Here is what I try
I added UINavigationControllerDelegate and adopt
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
[viewController viewWillAppear:animated];
}
-(void)viewWillAppear
{
NSLog(@"Log");
}
but viewWillAppear is still not invoked
EDIT
AppDelegate.m
self.navigationController = [[UINavigationController alloc]init];
[self.window setRootViewController:self.navigationController];
FirstView *fview = [FirstView]alloc]init];
[self.viewController pushViewController:fview animated:YES];
FirstView.m
....
-(void)viewWillAppear
{
NSLog(@"Logged");
}
....
Upvotes: 0
Views: 1635
Reputation: 52565
The clue is here:
[viewController viewWillAppear:animated];
}
-(void)viewWillAppear
You call a method that takes one parameter. But your method doesn't have one. In Objective C terms that's a completely different method.
It should look like this:
-(void)viewWillAppear:(BOOL)animated {
// blah
}
Upvotes: 6
Reputation: 5038
do you have navigation controller on window? paste your appdelegate.m
my working code:
self.navController = [[[CustomNavigationController alloc] initWithRootViewController:[[[HomeViewController alloc] init] autorelease]] autorelease];
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
Upvotes: 0