objective-c - 确定 iPhone 何时平放

标签 objective-c

是否有办法确定 iPhone 何时处于背面放置状态?

这是在一个表面上,或者用户将其握在手中,然后移动手机,使其平放在半空中。

我知道 iPhone 有陀螺仪和加速计,但我不确定如何使用它们来找出这一点。

最佳答案

看看UIDeviceOrientation :

typedef NS_ENUM(NSInteger, UIDeviceOrientation) {
    UIDeviceOrientationUnknown,
    UIDeviceOrientationPortrait,            // Device oriented vertically, home button on the bottom
    UIDeviceOrientationPortraitUpsideDown,  // Device oriented vertically, home button on the top
    UIDeviceOrientationLandscapeLeft,       // Device oriented horizontally, home button on the right
    UIDeviceOrientationLandscapeRight,      // Device oriented horizontally, home button on the left
    UIDeviceOrientationFaceUp,              // Device oriented flat, face up
    UIDeviceOrientationFaceDown             // Device oriented flat, face down
};

关于objective-c - 确定 iPhone 何时平放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30564995/

相关文章:

iOS - 如何在 View Controller 中设置导航栏项目?

iphone - iOS 动画启动画面

iphone - 如何在主视图中定位 subview ?

objective-c - 如何区分未设置的 float 和值为 0 的 float ?

iphone - 用于内存管理的 dealloc 与 ViewDidDissapear

objective-c - 为什么 'no known method for selector x'在ARC下是硬错误?

objective-c - 向 rightBarButtonItems 添加两个按钮不起作用

objective-c - 我可以在带有 subview 的 NSView 上设置 layer.transform 吗?

ios - NSURLSession 委托(delegate) didCompleteWithError 未调用

ios - 从 url 获取 alasset 对象数组