UIPageViewController重置为旋转的第一页

当用户旋转他们的设备时, UIPageViewController从显示的任何页面淡出到第一页。 这真的很烦人,特别是当用户多页进入文档。 它只发生在iOS 6。

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

 - (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation { return UIPageViewControllerSpineLocationMin; } 

我总是希望脊椎在左边。

你有什么想法是什么导致UIPageViewController重置? 我在这里发现了一个错误报告,但我一直无法在网上find任何其他信息,让我觉得我做错了什么。

你的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; } 

我不知道这样的错误存在,但最坏的情况下,你可以覆盖

 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; 

捕捉旧状态并在转换完成后重新设置它。 我很想相信还有别的东西会导致这个问题,但没有更多的数据,我不能说。 你可以发布更多的UIPageViewController代码?

我遇到过同样的问题。 我发现简单地删除我的spineLocationForInterfaceOrientation实施修复了我。