美文网首页
childViewController

childViewController

作者: yaya_pangdun | 来源:发表于2016-07-24 18:05 被阅读82次
    //默认显示在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];
    

    相关文章

      网友评论

          本文标题:childViewController

          本文链接:https://www.haomeiwen.com/subject/ohwvjttx.html