CMMotionManager - 专门使用CMMotionManager进行标题 [英] CMMotionManager - getting heading using CMMotionManager exclusively
问题描述
我已经设法使用CLLocationManager获取指南针标题,但因为我的应用程序已经使用CMMotionManager我想使用专门的CMMotionManager测量标题。
I have managed to get compass heading using CLLocationManager but because my app already uses CMMotionManager I would like to measure heading using exclusively CMMotionManager.
像所有Apple模糊文档一样,你必须猜测如何使用他们的API。
Like all Apple vague documentation, you have to guess how to use their APIs.
我试图用它来衡量标题
[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);
}];
问题是此块只运行几秒钟然后停止运行。
the problem is that this block runs just a few seconds then stop running.
有没有关于如何使用CMMotionManager专门测量航向的示例?
Is there any example of how to measure heading using CMMotionManager exclusively?
谢谢。
推荐答案
显然,最好的方法是使用CoreLocation,直到Apple创建合适的文档。
Apparently the best way to do it is using CoreLocation, until Apple creates decent documentation.
这篇关于CMMotionManager - 专门使用CMMotionManager进行标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!