CMCalibratedMagneticField
은 항상 0
을 반환합니다.CMCalibratedMagneticField가 업데이트되지 않습니다.
CMAcceleration
은 CMMagnetometerData
값도 반환합니다. CMCalibratedMagneticField
만이 아니기 때문에 바이어스가없는 자기장이기 때문에 필요합니다.
iPhone 4S에서 테스트 중입니다.
[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)];
}];