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

标签 ios uiviewcontroller ios8 uikit uiinterfaceorientation

既然 UIViewController 中的 interfaceOrientation 属性已弃用,那么检测当前设备方向的推荐方法是什么?

最佳答案

您可以使用[UIApplication sharedApplication].statusBarOrientation

请注意 [[UIDevice currentDevice] orientation] 与您的应用程序旋转不完全。文档:

Discussion: The value of the property is a constant that indicates the current orientation of the device. This value represents the physical orientation of the device and may be different from the current orientation of your application’s user interface. See UIDeviceOrientation for descriptions of the possible values.

我会检查 statusBarOrientation 是否有效。

关于ios - 如何知道 iOS 8 中的当前 interfaceOrientation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27966880/

相关文章:

ios - 如何在 xib 中为不同的 UIViewcontroller 设置不同的导航栏颜色?

ios - Xcode 6 - 如何为 Ad-Hoc 分发选择签名证书/配置文件?

javascript - ionic 应用程序崩溃问题

ios - 如何将数据从 viewController 分配给 tableViewCell 标签?

xcode - 我为什么要使用静态库?

objective-c - Swift 和 Xcode 6.1 的布局问题

iOS 8 UIImagePickerController 只拍照片的照片

ios - XCTest 期望使用 swift 调用方法

ios - 协议(protocol)委托(delegate)方法和 block 之间的连接区别

ios - Firebase 谷歌登录崩溃 Swift