hpi*_*que 3 iphone uiviewcontroller uiinterfaceorientation ios ios5
考虑一个带有两个子视图控制器(A和B)的容器视图控制器,两者都添加了addChildViewController:.然后:
A.view 被添加到容器视图中transitionFromViewController从A到B显示.B接收viewWillLayoutSubviews并且全世界都很好.willRotateToInterfaceOrientation:全部).transitionFromViewController从B到A 显示A.A不接收viewWillLayoutSubviews,因此布局被破坏.这是预期的行为吗?如果没有,我可能做错了什么?如果是,我应该怎么做才能在显示B时通知A旋转变化?
一旦打电话,addChildViewController:您现在就成为View Controller Container Implementer.这意味着你必须做一些比标准演示调用更多的工作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];
}];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3381 次 |
| 最近记录: |