为了在拍照时检测手机的方向,我使用

orientation == UIDeviceOrientationLandscapeRight
orientation == UIDeviceOrientationPortraitUpsideDown
orientation == UIDeviceOrientationPortrait
orientation == UIDeviceOrientationLandscapeLeft

但如果从侧面拍摄照片,这些方法就有效。如何检查 iPhone 是否向下倾斜至平整状态,例如:拍摄航拍照片时?

有帮助吗?

解决方案

有存在该设备取向其他常数:

typedef enum {
   UIDeviceOrientationUnknown,
   UIDeviceOrientationPortrait,
   UIDeviceOrientationPortraitUpsideDown,
   UIDeviceOrientationLandscapeLeft,
   UIDeviceOrientationLandscapeRight,
   UIDeviceOrientationFaceUp,
   UIDeviceOrientationFaceDown
} UIDeviceOrientation;

您可以在这里找到他们:的的UIDevice类参考

其他提示

看一下 UIAccelerometer (和 UIAccelerometerDelegate)必须用于检测设备运动的类。
编辑: 在 UIAccelerometer 类参考中,有 3 个相关示例的链接: 加速度计图, GL重力GL画图

有在 http://developer.apple.com/iphone样品应用该图表生来自加速度计的数据。您的设备上安装它,看看你得到的数据类型。

在样品应用程序具有一个选项(我认为这是“阻尼”),有效地抵消了重力。你不想这样做 - 其实重力是怎么回事Z轴“加速”您的设备时,它的平...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top