在iPhone X上无法将界面方向旋转为纵向倒置

时间:2017-10-05 07:47:17

标签: ios objective-c xcode9 iphone-x

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

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

设置方向的当前代码:

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

1 个答案:

答案 0 :(得分:6)

似乎iPhone X不支持倒置方向;见https://forums.developer.apple.com/message/268015。一位苹果员工表示,“这是设计原因。我们将在未来的版本中更新文档,以反映这一点。”

至少在SIM卡中,您仍然可以获得方向更改通知,但正如您所发现的那样,如果您采取行动,可能会发生不良事件。在我的情况下,我没有得到异常,但我的UI没有正确重绘。

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

结果是,我们这些使用照明端口传感器想要在顶部的人将无法为iPhone X用户提供与“较小”iPhone相同的可用性,至少在没有一些严重繁琐的UI jiggery-pokery的情况下涉及大量仿射变换以旋转和/或翻转元素以出现倒置,同时仍然符合手机认为所做的事情。叹息。

相关问题