I solved this difficulty.
In fact, SecondVC has been rotated correctly, or at least the location of the spine has been changed correctly. Therefore, when I turned the device, and SecondVC was not the active view controller in the parent view, it received HAS rotation messages and pageViewController: spineLocationForInterfaceOrientation:. I set the right spine location for the new interface orientation and called setViewControllers on the SecondVC page view controller. The problem was that even if I installed two view controllers for UIPageViewControllerSpineLocationMid , after displaying SecondVC there was only one left, for example, in UIPageViewControllerSpineLocationMin.
I have a βfixedβ problem by installing the view controllers again in the page view controller in viewWillAppear: because when this method is called, the spine location for the page view controller is correct and based on this, the information I set is two pages (controllers view)
- (void)viewWillAppear:(BOOL)animated { if(m_pageController.spineLocation == UIPageViewControllerSpineLocationMid) { LeftPageController *left; RightPageController *right; if(m_pageController.viewControllers.count > 0) { left = [m_pageController.viewControllers objectAtIndex:0]; right = [m_storyboard instantiateViewControllerWithIdentifier:@"rightPage"]; [right loadView]; } [m_pageController setViewControllers:[NSArray arrayWithObjects:left, right, nil] direction:UIPageViewControllerNavigationDirectionForward | UIPageViewControllerNavigationDirectionReverse animated:NO completion:nil]; [m_left hideGallery]; } if(m_pageController.spineLocation == UIPageViewControllerSpineLocationMin) { [m_pageController setViewControllers:[NSArray arrayWithObject:[m_pageController.viewControllers objectAtIndex:0]] direction:UIPageViewControllerNavigationDirectionForward | UIPageViewControllerNavigationDirectionReverse animated:NO completion:nil]; } [super viewWillAppear:animated]; } - (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation { if(UIInterfaceOrientationIsPortrait(orientation)) { LeftPageController *left = [pageViewController.viewControllers objectAtIndex:0]; [pageViewController setViewControllers:[NSArray arrayWithObject:left] direction:UIPageViewControllerNavigationDirectionForward | UIPageViewControllerNavigationDirectionReverse animated:NO completion:nil]; pageViewController.doubleSided = NO; return UIPageViewControllerSpineLocationMin; } if(UIInterfaceOrientationIsLandscape(orientation)) { LeftPageController *left; RightPageController *right; if(pageViewController.viewControllers.count > 0) { left = [pageViewController.viewControllers objectAtIndex:0]; right = [m_storyboard instantiateViewControllerWithIdentifier:@"rightPage"]; [right loadView]; } [pageViewController setViewControllers:[NSArray arrayWithObjects:left,right, nil] direction:UIPageViewControllerNavigationDirectionForward | UIPageViewControllerNavigationDirectionReverse animated:NO completion:nil]; return UIPageViewControllerSpineLocationMid; } return UIPageViewControllerSpineLocationMin; }
I know that I am doing the same thing twice, but this is the price that I am willing to pay in this case. Why, after calling pageViewController: spineLocationForInterfaceOrientation: and setting two view controllers for Landscape, when SecondVC is inactive, only one ViewController in m_pageController in viewWillAppear: after activation, SecondVC remains a mystery to me.
source share