//默认显示在self.view中
[self addChildViewController:firstVC];
// addChildViewController回调[child willMoveToParentViewController:self]
// 但是不会调用didMoveToParentViewController,所以需要显示调用
[firstVC didMoveToParentViewController:self];
_currentVC = firstVC;
//切换childViewController
[self transitionFromViewController:currentViewController toViewController:firstViewController duration:4 options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ }
completion:^(BOOL finished) { //...... }];
//移除child view controller
// removeFromParentViewController在移除child前不会调用[self willMoveToParentViewController:nil] ,
//所以需要显示调用
[_currentVC willMoveToParentViewController:nil];
[_currentVC removeFromSuperview];
[_currentVC removeFromParentViewController];
网友评论