I have a UIViewController that contains other ViewControllers. Initial ViewController is set in viewDidLoad:
FirstViewController *first = [FirstViewController alloc] init];
first.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
first.view.frame = m_content.frame;
[self addChildViewController:first];
[m_content.view addSubview:first.view];
[first didMoveToParentViewController:self];
m_activeViewController = first;
This Container Controller has implemented automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers to return YES. It has also implemented to manualy forward rotation changes to non active ViewControllers
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
for(UIViewController *vc in m_viewControllers)
{
if(vc != [m_activeViewController]
[vc willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
for(UIViewController *vc in m_viewControllers)
{
if(vc != [m_activeViewController]
[vc didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
When menu button is tapped i make the transition between ViewControllers.
- (void)onMenuItemTapped:(id)sender
{
UIViewController *vc = [m_viewControllers objectAtIndex:sender.tag];
vc.view.frame = m_content.frame;
[self addChildViewController:vc];
[self transitionFromViewController:m_activeViewController toViewController:vc duration:0 options:UIViewAnimationOptionTransitionNone animations:nil completion:^(BOOL finished) {
[vc didMoveToParentViewController:self];
[m_activeViewController removeFromParentViewController];
m_activeViewController = vc;
}];
}
This transition works fine for my "normal" ViewControllers and they are displayed properly after orientation changes, even if they are not active. However, one of these Child View Controllers, called SecondCV, has UIPageViewController as a Child View Controller. I have UIPageViewControllerDelegate and UIPageViewControllerDataSource set to this SecondCV and in pageViewController:spineLocationForInterfaceOrientation: I return UIPageViewControllerSpineLocationMin for Portrait and UIPageViewControllerSpineLocationMid for Landscape. Rotation for this SecondVC works correctly when its active - there are two pages on the landscape and one on the portrait mode displayed correctly. But when this SecondVC is not active the rotation is incorrect. Even if pageViewController:spineLocationForInterfaceOrientation: is called, there is still one page in both Portrait and Landscape mode. I am trying to fix this for some time, but i dont see any other options. Do you have any ideas how to fix this?
Thank you.