出于某种原因,我的 iPad2 没有提供运动姿态信息。我正在按照人们所说的去做AFAIK,但仍然……没有数据。
float angle = 0;
CMDeviceMotion *deviceMotion;
CMAttitude *attitude;
deviceMotion = motionManager.deviceMotion;
if (deviceMotion) {
attitude = deviceMotion.attitude;
[attitude multiplyByInverseOfAttitude:referenceAttitude];
angle = [attitude roll];
} else {
NSLog (@"Cannot get angles.");
}
在我的代码前面,我这样做:
motionManager = [[CMMotionManager alloc] init];
if (motionManager.gyroAvailable) {
[motionManager startGyroUpdates];
}
但是我从来没有得到角度。帮助?