CMCalibratedMagneticField
常に戻ります0
。
CMAcceleration
値をCMMagnetometerData
返し、値も返します。バイアスCMCalibratedMagneticField
のない磁場なので、必要ありません。
私はiPhone4Sでテストしています。
[MotionManager startDeviceMotionUpdatesToQueue:deviceQueue
withHandler:^(CMDeviceMotion *motion, NSError *error) {
CMCalibratedMagneticField f = motion.magneticField;
//CMMagneticField t = motion.;
//CMAcceleration s = motion.gravity; Works!
//_xlabelnew.text = [NSString stringWithFormat:@"%f", s.x];
_xlabelnew.text = [NSString stringWithFormat:@"%f", f.field.x];
_ylabelnew.text = [NSString stringWithFormat:@"%f", f.field.y];
_zlabelnew.text = [NSString stringWithFormat:@"%f", f.field.z];
//_totallabelnew.text = [NSString stringWithFormat:@"%f", sqrt(f.field.x*f.field.x + f.field.y*f.field.y + f.field.z*f.field.z)];
}];