我已经编写了这段代码来从 xcode 中的 UIAccelerometer 获取 G 值。你能告诉我它是否正确吗?
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
float gValue = sqrt(acceleration.x*acceleration.x+acceleration.y*acceleration.y+acceleration.z*acceleration.z);
[gLabel setText:[NSString stringWithFormat:@"%.2f",gValue]];
}
请帮助我