【问题标题】:Child views of UIPageViewController (SpineLocationMid) have strange framesUIPageViewController (SpineLocationMid) 的子视图有奇怪的帧
【发布时间】:2013-06-15 14:32:43
【问题描述】:

我有一个以编程方式实现 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 显示两个页面,在我开始分页之前它看起来很好。问题是:它的一个子视图控制器(在我开始翻转的一侧)占用了设备屏幕的所有空间,因此另一个页面隐藏在它下面。 在 childViewController 的课程中​​,我发现在 -(void)viewWillAppear 方法中,框架的宽度很好(我需要它是 512 - 我屏幕的一半),但在 -(void)viewDidAppear 方法中它已经是 1024。

【问题讨论】:

    标签: objective-c cocoa-touch uikit uipageviewcontroller


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      只需设置为我的 ChildViewController setWantsToFullScreenLayout:NO 即可解决问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-04-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-10
        • 1970-01-01
        相关资源
        最近更新 更多