0
我正在开发一款仅支持横向方向的iPad应用。我用这两种方法到一个新的子视图控制器添加到我的容器视图控制器:iOS容器视图控制器在纵向方向上添加儿童视图
如图的问题是,子视图控制器的观点是纵向且将其打乱了意见
- (void) assignFirstChildViewController:(UIViewController*)controller
{
self.currentChildViewController = controller;
[self addChildViewController:self.currentChildViewController];
[self.currentChildViewController didMoveToParentViewController:self];
[self.containerView addSubview:self.currentChildViewController.view];
}
- (void)assignNewChildController:(UIViewController *)childViewController
{
id currentChildViewController = self.currentChildViewController;
if(!currentChildViewController){
[self assignFirstChildViewController:childViewController];
}else{
[self.currentChildViewController willMoveToParentViewController:nil];
[self addChildViewController:childViewController];
__weak __block PTSBaseContainerViewController *weakSelf=self;
[self transitionFromViewController:self.currentChildViewController
toViewController:childViewController
duration:1.0
options:0
animations:^{
[UIView transitionFromView:self.currentChildViewController.view toView:childViewController.view duration:1.0 options:UIViewAnimationOptionTransitionCrossDissolve completion:NULL];
}
completion:^(BOOL finished) {
[weakSelf.currentChildViewController removeFromParentViewController];
weakSelf.currentChildViewController = childViewController;
[weakSelf.currentChildViewController didMoveToParentViewController:weakSelf];
}];
}
}
下面的图片:
绿色的观点是子视图控制器,你可以看到在纵向模式中添加的视图。它不是占据整个黄色视图(这是容器视图,它占据了视图控制器的整个框架,位于灰色顶部栏下方),而是以纵向模式添加,我无法弄清楚原因。
PS:我试图覆盖shouldAutomaticallyForwardRotationMethods
和shouldAutomaticallyForwardAppearanceMethods
在苹果文档中写入,但没有结果。