如何知道iOS 8中的当前interfaceOrientation?

coc*_*est 4 uiviewcontroller uikit uiinterfaceorientation ios ios8

现在,interfaceOrientation属性格式中UIViewController已过时,什么是检测当前设备的方向推荐的方法是什么?

ore*_*ren 11

您可以使用 [UIApplication sharedApplication].statusBarOrientation

注意这[[UIDevice currentDevice] orientation]不完全喜欢你的应用程序旋转.文档:

讨论: 属性的值是一个常量,表示设备的当前方向.此值表示设备的物理方向,可能与应用程序用户界面的当前方向不同.有关可能值的说明,请参阅UIDeviceOrientation.

我会检查statusBarOrientation是否有效.