I am using MSNavigationPaneViewController
from here and have rotation sort of working.
I've overridden the rotation methods in my root UINavigationController
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (appDelegate.topViewController != nil) {
return [appDelegate.topViewController supportedInterfaceOrientations];
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (appDelegate.topViewController != nil) {
return [appDelegate.topViewController preferredInterfaceOrientationForPresentation];
} else {
return UIInterfaceOrientationPortrait;
}
}
which I push the MSNavigationPaneViewController
with using presentViewController: animated:completion:
and I have rotation working so certain views can have different orientations. The problem is, each view that has a different orientation needs the user to tilt the phone to change the orientation at which point it locks on the correct orientation.
I've done tons of reading to get this working and it seems I need preferredInterfaceOrientationForPresentation
to fire before each view is loaded, but it's not firing.
I think it's not firing because the MSNavigationPaneViewController
isn't changing view controllers using presentViewController
.
This is the code used by MSNavigationPaneViewController
to change the view
- (void)setPaneViewController:(UIViewController *)paneViewController
{
if (_paneViewController == nil) {
paneViewController.view.frame = _paneView.bounds;
_paneViewController = paneViewController;
[self addChildViewController:_paneViewController];
[_paneView addSubview:_paneViewController.view];
[_paneViewController didMoveToParentViewController:self];
} else if (_paneViewController != paneViewController) {
paneViewController.view.frame = _paneView.bounds;
[_paneViewController willMoveToParentViewController:nil];
[self addChildViewController:paneViewController];
void(^transitionCompletion)(BOOL finished) = ^(BOOL finished) {
[_paneViewController removeFromParentViewController];
[paneViewController didMoveToParentViewController:self];
_paneViewController = paneViewController;
};
[self transitionFromViewController:_paneViewController
toViewController:paneViewController
duration:0
options:UIViewAnimationOptionTransitionNone
animations:nil
completion:transitionCompletion];
}
}
which looks like it's just switching the viewController and therefor not calling preferredInterfaceOrientationForPresentation
Is there any way to force preferredInterfaceOrientationForPresentation
to be called, or to trick it into be called maybe by a hidden view?
Thanks
EDIT ----
I totally understand how the new rotation system works in iOS6 and that it's down to the root to manage it. However preferredInterfaceOrientationForPresentation
only seems to be called if the next view is being presented
with one of the correct methods. Not if the window is just switched.
So I do actually need a way to trick this to be called.