Cannot rotate interface orientation to portrait upside down on iPhone X

偶尔善良 提交于 2021-02-07 07:27:20

问题


We have an app which makes use of an accessory connected to the audio jack(or lightning port in iPhone7 or later).It needs to be run in certain orientations, depending on iOS device.

There are currently no issues setting device orientation in either simulator or actual device for any iPhone, except the iPhoneX simulator.

Current code for setting orientation:

- (BOOL)shouldAutorotate {
    return YES;
}

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

Target settings with orientations enabled

Stack trace:

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'

This is working on iPhone5, iPhone6, iPhone6+, iPhone7 and iPhone7+ devices and iPhone8 simulators. It doesn't seem to be an iOS11 issue either as my iPhone7 is currently running iOS11. The only device I'm currently having issues with is the iPhoneX simulator.


回答1:


It appears that the iPhone X will not support upside-down orientation; see https://forums.developer.apple.com/message/268015. An Apple staffer says, "It is by design. We're getting documentation updated in a future release to reflect that."

You still get the orientation change notification, at least in the sim, but as you found, Bad Things may happen if you act on it. In my case I don't get an exception, but my UI doesn't redraw properly.

I'm adding code to detect an upside-down iPhone X and prevent the UI redraw; it works in the sim, and we'll have to wait and see if it'll work on the real device (fortunately my use case for upside-down only involves a headphone-jack device, so loss of upside-down on iPhone X isn't a big deal for me).

The upshot is that those of us using lighting port Sensors That Want To Be On Top will not be able to offer iPhone X users the same usability as on "lesser" iPhones, at least not without some seriously tedious UI jiggery-pokery involving lots of affine transforms to rotate and/or flip elements to appear upside-down while still conforming to what the phone thinks it's doing. Sigh.



来源:https://stackoverflow.com/questions/46580472/cannot-rotate-interface-orientation-to-portrait-upside-down-on-iphone-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!