5

我们有一个应用程序使用连接到音频插孔(或 iPhone7 或更高版本中的闪电端口)的附件。它需要以特定方向运行,具体取决于 iOS 设备。

目前在任何 iPhone 的模拟器或实际设备中设置设备方向都没有问题,除了 iPhoneX 模拟器。

当前设置方向的代码:

- (BOOL)shouldAutorotate {
    return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    //device checks omitted
    return UIInterfaceOrientationMaskPortraitUpsideDown;
}

启用方向的目标设置

堆栈跟踪:

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 模拟器。

4

1 回答 1

7

iPhone X 似乎不支持倒置方向;请参阅https://forums.developer.apple.com/message/268015。一位 Apple 员工说:“这是设计使然。我们将在未来的版本中更新文档以反映这一点。”

至少在模拟中,您仍然会收到方向更改通知,但正如您发现的那样,如果您采取行动,可能会发生坏事。就我而言,我没有遇到异常,但我的 UI 没有正确重绘。

我正在添加代码来检测倒置的 iPhone X 并防止 UI 重绘;它可以在 sim 中运行,我们将不得不等待,看看它是否可以在真实设备上运行(幸运的是,我的颠倒用例仅涉及耳机插孔设备,因此在 iPhone X 上失去颠倒对我来说没什么大不了的)。

结果是,我们这些使用照明端口传感器的人将无法为 iPhone X 用户提供与“较小”iPhone 相同的可用性,至少在没有一些严重乏味的 UI 游戏中,涉及大量仿射变换旋转和/或翻转元素以颠倒显示,同时仍符合手机认为正在做的事情。叹。

于 2017-10-21T02:06:30.923 回答