Determining the Orientation of the screen rather than the orientation of the device

白昼怎懂夜的黑 提交于 2019-12-03 09:50:50
Chamara Paul

Have you tried using UIInterfaceOrientationPortrait/UIInterfaceOrientationLandscape? I usually have pretty good results using these methods:

if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) {
    //do portrait work
} else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){
    //do landscape work
}

You might also try UIDeviceOrientationIsValidInterfaceOrientation.

These will only return the app's orientation, which may not be the same as the device's orientation.

If those don't work, you can also try:

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