我正在运行iOS 7.0.4的iPhone 5和iPod(第5代)上执行以下代码。在iPhone上,更新几乎是实时的,而在iPod上有一个显着的延迟。我做错了什么导致这种差异?它们不应该是一样的吗?
motionManager = [[CMMotionManager alloc] init];
motionManager.accelerometerUpdateInterval = 1.0/20.0; // Update at 20Hz
if (motionManager.accelerometerAvailable) {
NSLog(@"Accelerometer avaliable");
queue = [NSOperationQueue currentQueue];
[motionManager startDeviceMotionUpdatesToQueue:queue
withHandler:^(CMDeviceMotion *accelerometerData, NSError *error) {
CMAcceleration useracceleration = accelerometerData.userAcceleration;
xLabel.text = [NSString stringWithFormat:@"%f", useracceleration.x];
xBar.progress = ABS(useracceleration.x);
yLabel.text = [NSString stringWithFormat:@"%f", useracceleration.y];
yBar.progress = ABS(useracceleration.y);
zLabel.text = [NSString stringWithFormat:@"%f", useracceleration.z];
zBar.progress = ABS(useracceleration.z);
force = (bodymass * sqrt((pow(useracceleration.x,2) + pow(useracceleration.y,2) + pow(useracceleration.z,2))));
forceLabel.text = [NSString stringWithFormat:@"%f", force];
forceBar.progress = ABS(force);
}];
}
请帮助...我希望此代码能够在两台设备上准确运行。谢谢!