App Orientation in iOS9 Split View

无人久伴 提交于 2019-12-08 07:35:48

问题


I'm looking at how my app will run in Split View on an iPad Pro. I use constraints for layout, but sometimes I want to know the window orientation in order to tweak the layout by modifying a couple of constraints.

Things are easy to handle if the user rotates the device (I handle the call of viewWillTransitionToSize), but the app has to know its initial orientation.

Until now, I have been using the status bar orientation to determine the device orientation: UIInterfaceOrientation o = [[UIApplication sharedApplication] statusBarOrientation];

But this doesn't seem to work properly in Split screen mode on the iPad Pro simulator. The problem is that the device is in landscape mode, and the statusbarOrientation call says the app is in landscape mode. But my app is using half the screen, so it needs to do layout as if it's in portrait mode.

If I check the bounds size of myViewController.view, this seems to give the right answer, even if the device has not been rotated. In the bad old days I seem to remember that we couldn't rely on this unless the device had been rotated at least once.

So what's the right way to determine the orientation of my App window in iOS9?

来源:https://stackoverflow.com/questions/32769432/app-orientation-in-ios9-split-view

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