我试图在watchOS4
上记录陀螺仪数据,但以下代码不会返回陀螺仪数据。
相同的代码适用于iOS。
manager = [[CMMotionManager alloc] init];
manager.gyroUpdateInterval = FPS;
[manager startDeviceMotionUpdates];
[manager startGyroUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler:^(CMGyroData *gyroData, NSError *error) {
if( error ) {
NSLog(@"Gyro is not available");
}else{
NSLog(@"Gyro is available");
gyro[0] = gyroData.rotationRate.x;
gyro[1] = gyroData.rotationRate.y;
gyro[2] = gyroData.rotationRate.z;}
}];