iphone - UIPageViewController 在旋转时重置为第一页

标签 iphone objective-c ios ipad uipageviewcontroller

当用户旋转他们的设备时,UIPageViewController 从它显示的任何页面淡出回到第一页。这真的很烦人,尤其是当用户将多个页面放入文档时。它只出现在 iOS 6 中。

当用户旋转他们的设备时,spineLocationForInterfaceOrientation 被调用,这可能与问题有关。

- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
               spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation {

    return UIPageViewControllerSpineLocationMin;

}

我总是希望书脊在左边。

你知道是什么导致 UIPageViewController 重置吗?我发现了一个错误报告 here , 但我一直无法在网上找到任何其他信息,让我觉得我做错了什么。

最佳答案

您的spineLocationForInterfaceOrientation 不完整

应该是这样的:

- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
                   spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
{

        UIViewController *currentViewController = self.pageViewController.viewControllers[0];
        NSArray *viewControllers = @[currentViewController];
        [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];

        return UIPageViewControllerSpineLocationMin;

}

关于iphone - UIPageViewController 在旋转时重置为第一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14132132/

相关文章:

ios - (cell == nil) 与 (!cell)

ios - 无法打开 .xib 文件

ios - Swift:添加 UIImage?

iphone - iOS - 导航标题未更新

iphone - 如何使循环异常?

objective-c - 将 xib View 初始化为另一个 NSView 的 subview

iphone - 如何使用 iPhone SDK 从 SQLite 数据库中获取原始特殊字符?

ios - 获取 .strings 文件的文本

ios - RMMapView map 设置区域

ios - 在 Swift 中存储数组并从数组中获取数据