viewDidAppear/viewWillAppear
When you push or pop a view controller on/off a navigaction controller's stack, the usual
@interface RootViewController : UIViewController <UINavigationControllerDelegate> {
UINavigationController *navController;
}
Then implement these two methods:
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[viewController viewWillAppear:animated];
}
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[viewController viewDidAppear:animated];
}
Be sure to set the root view controller as the delegate for the nav controller. Now
If you want to call the viewWillDisappear/viewDidDisappear methods, your view controller still has to do that manually before popping itself off the nav stack.
在iOS应用中,当使用UINavigationController管理视图控制器堆栈时,有时viewWillAppear和viewDidAppear方法不会被调用。通过将根视图控制器设置为UINavigationControllerDelegate,可以确保这些方法总是被调用。
2668

被折叠的 条评论
为什么被折叠?



