【发布时间】:2017-09-22 19:51:19
【问题描述】:
对于 iOS 10 及更低版本,以下代码控制任何相应 UIViewController 的方向。我在部署信息中选择了Portrait、Landscape Left 和Landscape Right,并且在我的Info.plist 中有以下内容:
对于我应该不轮换的 VC,我有以下代码,我说过,在 iOS 11
之前可以运行- (BOOL)shouldAutorotate {
[super shouldAutorotate];
return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
[super supportedInterfaceOrientations];
return UIInterfaceOrientationMaskPortrait;
}
我已经在实际设备上对此进行了测试,但从 iOS 11 开始它不起作用。
更奇怪的是,从 iOS 11 开始记录已注册的设备方向会告诉我设备 IS 纵向...当控制器以横向模式加载时...
代码:
// In viewDidLoad
NSLog(@"orientation: %lu", [[UIDevice currentDevice] orientation]);
控制台输出:
2017-09-22 15:20:26.225196-0400 <APP_NAME>[2669:1628408] orientation: 1
在构建和运行应用程序之前左右旋转设备都会发生这种情况。
- 此错误的原因是什么?如果有人知道请帮忙..
仅供参考:不,我的设备上没有旋转锁定..
【问题讨论】:
标签: ios objective-c swift orientation ios11