我MSNavigationPaneViewController
从这里使用并且有轮换工作。我已经覆盖了我的根目录中的旋转方法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;
}
}
MSNavigationPaneViewController
我用 using推动它,presentViewController: animated:completion:
并且我有旋转工作,因此某些视图可以有不同的方向。问题是,每个具有不同方向的视图都需要用户倾斜手机来改变方向,在该点锁定正确的方向。我已经做了大量的阅读以使其正常工作,似乎我需要preferredInterfaceOrientationForPresentation
在加载每个视图之前触发,但它没有触发。我认为它没有触发,因为MSNavigationPaneViewController
没有使用presentViewController
. 这是用于MSNavigationPaneViewController
更改视图的代码
- (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];
}
}
看起来它只是切换 viewController 并因此不调用preferredInterfaceOrientationForPresentation
有什么方法可以强制preferredInterfaceOrientationForPresentation
被调用,或者通过隐藏视图诱骗它被调用?
谢谢
编辑 - -
我完全理解新的轮换系统在 iOS6 中是如何工作的,并且它是由根来管理的。但是,如果下一个视图使用正确的方法之一,preferredInterfaceOrientationForPresentation
似乎只会被调用。presented
如果窗口刚刚切换,则不会。所以我确实需要一种方法来欺骗这个被调用。