更新时间:2023-02-02 17:24:08
实际上非常简单,只需使用参考框架开始生成设备动作更新:
Its quite simple actually, just start generating device motion updates using a reference frame:
- (void)startDeviceMotionUpdatesUsingReferenceFrame:(CMAttitudeReferenceFrame)referenceFrame
根据您想要达到的目的,您可以选择其中一个不同的选项
Depending on what you want to achieve you can select one of the different options
typedef enum {
CMAttitudeReferenceFrameXArbitraryZVertical = 1 << 0,
CMAttitudeReferenceFrameXArbitraryCorrectedZVertical = 1 << 1,
CMAttitudeReferenceFrameXMagneticNorthZVertical = 1 << 2,
CMAttitudeReferenceFrameXTrueNorthZVertical = 1 << 3
} CMAttitudeReferenceFrame;
例如,通过使用CMAttitudeReferenceFrameXMagneticNorthZVertical,您从加速度获得的读数将是恒定的,无论设备位置(它们与重力对齐前方和北方)。我不记得确切的参考位置,但我相信手机顶部指向北方,而手机屏幕指向up。
For example, by using "CMAttitudeReferenceFrameXMagneticNorthZVertical" the readings you get from the acceleration would be constant regardless of the device position (they get aligned with "gravity" bellow" and "north" in front). I don't remember the exact reference position but i believe the "top of the phone" points north while the "screen of the phone" points up.