现在我正在使用以下代码从设备的陀螺仪中获取欧拉值。这是应该如何使用的吗?或者有没有更好的方法不使用 NSTimer?
- (void)viewDidLoad {
[super viewDidLoad];
CMMotionManager *motionManger = [[CMMotionManager alloc] init];
[motionManger startDeviceMotionUpdates];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:(1/6) target:self selector:@selector(read) userInfo:nil repeats:YES];
}
- (void)read {
CMAttitude *attitude;
CMDeviceMotion *motion = motionManger.deviceMotion;
attitude = motion.attitude;
int yaw = attitude.yaw;
}