【子视图控制器的lifeCycle】
@interface UIViewController (UIContainerViewControllerCallbacks)
- (BOOL)shouldAutomaticallyForwardAppearanceMethods NS_AVAILABLE_IOS(6_0);
//该方法返回NO则childViewController不会自动viewWillAppear和viewWillDisappear对应的方法 - (BOOL)shouldAutomaticallyForwardAppearanceMethods { return NO; }
//都写在子视图控制器中。
- (void)willMoveToParentViewController:(UIViewController *)parent NS_AVAILABLE_IOS(5_0);
- (void)didMoveToParentViewController:(UIViewController *)parent NS_AVAILABLE_IOS(5_0);
-(void)willMoveToParentViewController:(UIViewController *)parent{ NSLog(@"willmoveto");//add时调用 } -(void)didMoveToParentViewController:(UIViewController *)parent{ NSLog(@"didmoveto");//remove时调用 }
@end