【问题标题】:How to force view controller orientation in iOS 10?如何在 iOS 10 中强制视图控制器方向?
【发布时间】:2016-10-24 11:30:45
【问题描述】:

我试过了:

--> 继承 UINavigationController 并覆盖 autorotate 方法

--> 覆盖 MyViewController 上的自动旋转方法

--> 两者都有。

注意:另外,我尝试使用自动旋转设置 NO 和 YES

这是我的代码:

NavigationControllerNoAutorotate:

@implementation NavigationControllerNoAutorotate

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationPortrait;
}

- (BOOL)shouldAutorotate {
    return YES;
}

@end

我的视图控制器:

- (BOOL)shouldAutorotate {
    return NO;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}


- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController {
    return UIInterfaceOrientationPortrait;
}

【问题讨论】:

  • 问题是我在 iPad 上进行测试,我在部署信息上激活了 SplitView。当“需要全屏”为“是”时,拆分视图被停用。
  • 我在这个链接上找到了解决方案:[link]*.com/questions/32782044/…

标签: uiviewcontroller uinavigationcontroller ios10 uiinterfaceorientation


【解决方案1】:

问题是我在 iPad 上进行测试,我在部署信息上激活了 SplitView。当“需要全屏”为“是”时,拆分视图被停用。

我在LINK找到了解决方案

【讨论】: