【发布时间】:2018-03-16 18:26:55
【问题描述】:
我们有一个应用程序使用连接到音频插孔(或 iPhone7 或更高版本中的闪电端口)的附件。它需要以特定方向运行,具体取决于 iOS 设备。
目前在任何 iPhone 的模拟器或实际设备中设置设备方向都没有问题,iPhoneX 模拟器除外。
当前设置方向的代码:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
//device checks omitted
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
Target settings with orientations enabled
堆栈跟踪:
TF uncaught exception reason : Supported orientations has no common orientation with the application, and [RootNavigationController shouldAutorotate] is returning YES
2017-10-05 09:35:02.692945+0200 [65045:74145368] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [RootNavigationController shouldAutorotate] is returning YES'
这适用于 iPhone5、iPhone6、iPhone6+、iPhone7 和 iPhone7+ 设备以及 iPhone8 模拟器。这似乎也不是 iOS11 的问题,因为我的 iPhone7 目前正在运行 iOS11。我目前唯一遇到问题的设备是 iPhoneX 模拟器。
【问题讨论】:
-
在 iOS 11.2 上 shouldAutorotate 不再被调用。所有旧的旋转代码似乎都已被弃用:UIViewController 的文档中的“从 iOS 8 开始,所有与旋转相关的方法都已弃用”。我也很难避免在 iPhone X 上旋转。
标签: ios objective-c xcode9 iphone-x