CLLocationManager を使用してコンパスの方位を取得できましたが、アプリは既に CMMotionManager を使用しているため、CMMotionManager のみを使用して方位を測定したいと考えています。
すべての Apple のあいまいなドキュメントと同様に、それらの API の使用方法を推測する必要があります。
これを使用して見出しを測定しようとしました
[self.motionManager setMagnetometerUpdateInterval:1.0/30.0]; //30 Hz
[self.motionManager startMagnetometerUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMMagnetometerData *magnetometerData, NSError *error) {
CMMagneticField compass = magnetometerData.magneticField;
NSLog(@"x: %f y:%f z:%f", compass.x, compass.y, compass.z);
}];
問題は、このブロックがほんの数秒実行されて停止することです。
CMMotionManager のみを使用してヘディングを測定する方法の例はありますか?
ありがとう。