UIPageViewController(SpineLocationMid)的子视图具有奇怪的帧

时间:2013-06-15 14:32:43

标签: objective-c cocoa-touch uikit uipageviewcontroller

我有一个以编程方式实现的UIPageViewController的IPad项目。当我将设备转为横向模式时,我将pageViewController的脊椎位置更改为Mid的委托方法:

-(UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation{
if (UIInterfaceOrientationIsPortrait(orientation)){
    ChildViewController *viewController = (ChildViewController *)[self pageControllerAtIndex:currentPageIndex];
    [pageViewController setViewControllers:@[viewController] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
    return UIPageViewControllerSpineLocationMin;
} else {
    ChildViewController *first = (ChildViewController *)[self pageControllerAtIndex:currentPageIndex];
    ChildViewController *second = (ChildViewController *)[self pageControllerAtIndex:currentPageIndex+1];
    [pageViewController setViewControllers:@[first,second] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
    return UIPageViewControllerSpineLocationMid;
}
}

然后我的UIPageViewController显示两个页面,它看起来很好,直到我开始pagging它。问题是:它的一个子视图控制器(在我开始翻转的那一侧)占用了设备屏幕的所有空间,因此另一个页面隐藏在它下面。 在childViewController的类中,我发现在 - (void)viewWillAppear方法中,帧的宽度都很好(我需要它是512 - 我的屏幕的一半),但是 - (void)viewDidAppear方法它已经是1024。

2 个答案:

答案 0 :(得分:0)

检查ChildViewController.view的自动调整大小掩码或布局约束,并确保其大小不受父视图大小的影响。

答案 1 :(得分:-1)

设置为我的ChildViewController setWantsToFullScreenLayout:NO解决了问题。