CoreMotion - magnetField is always 0

I am trying to use a 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;
}];

And the filed (x, y, z) is always 0. It is motion.magneticField.accuracyalways CMMagneticFieldCalibrationAccuracyUncalibrated. According to the docs, this means that my device does not have a magnetometer, however this is not the real reason why I am testing iPad2 with iOS 5.0.

What am I missing?

+3
source share
1 answer

to try

startDeviceMotionUpdatesUsingReferenceFrame: toQueue: withHandler:

he should work

+6
source

All Articles