CoreMotion - magnetField始终为0 [英] CoreMotion - magneticField is always 0

查看:168
本文介绍了CoreMotion - magnetField始终为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用磁力计:

I'm trying to use magnetometer:

[myMotionMngr startDeviceMotionUpdatesToQueue: [NSOperationQueue currentQueue]
                                  withHandler:^(CMDeviceMotion *motion, NSError *error) 
{
    printf("%f\t%f\t%f\n", motion.magneticField.field.x, motion.magneticField.field.y, motion.magneticField.field.z);
    CMMagneticFieldCalibrationAccuracy acc = motion.magneticField.accuracy;
}];

并且归档(x,y,z)始终为0.
motion.magneticField.accuracy 总是 CMMagneticFieldCalibrationAccuracyUncalibrated 。根据文档,这意味着我的设备没有磁力计,但这不是真的,因为我正在使用iOS 5.0在iPad2上进行测试。

And the filed (x,y,z) is always 0. motion.magneticField.accuracy is always CMMagneticFieldCalibrationAccuracyUncalibrated. According to docs it means that my device has got no magnetometer, however it is no true cause I'm testing on iPad2 with iOS 5.0.

我缺少什么?

推荐答案

尝试

startDeviceMotionUpdatesUsingReferenceFrame:toQueue:withHandler:

startDeviceMotionUpdatesUsingReferenceFrame:toQueue:withHandler:

它应该有效

这篇关于CoreMotion - magnetField始终为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆