只要你拨打addChildViewController:
你现在是一个视图控制器容器实施者。这意味着你必须做一些比标准演示电话如presentViewController..
更多的工作。这包括处理作为孩子添加的控制器视图的框架,因为您的问题表明您可能已经预料到了。
例如,要实现一个超级基本示例容器,它只显示每个孩子的全屏,你可以做这样的事情。
-(void)swapChildVCFrom:(UIViewController *)from to:(UIViewController *)to{
[self addChildViewController:to];
[from willMoveToParentViewController:nil];
// Adjust the new child view controller's view's frame
// For example here just set it to fill the parent view
to.view.frame = self.view.bounds;
[self transitionFromViewController:from
toViewController:to
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:nil
completion:^(BOOL b){
[to didMoveToParentViewController:self];
[from.view removeFromSuperview];
[from removeFromParentViewController];
}];
}
在调用'transitionFromViewController'之前更新下一个视图控制器视图的框架不是更合适吗?奇怪,但。我认为这将由容器视图控制器以某种方式处理,因为这是一个相当常见的情况。 – hpique
@hpique由于'A.view'不旋转,其边界永远不会改变。因此,它应该只在第一次加载时才接收一次'viewWillLayoutSubviews'。 – Garrett