【发布时间】:2011-09-29 23:59:09
【问题描述】:
我正在创建接收陀螺仪俯仰、滚动和偏航的测试应用程序。
此代码无法正常工作:
- (void) enableGyro {
motionManager.deviceMotionUpdateInterval = 1.0/30.0;
if (motionManager.gyroAvailable) {
[motionManager startGyroUpdates];
}
NSLog(@"Gyro Available? %@", (motionManager.gyroAvailable ? @"YES" : @"NO"));
NSLog(@"Gyro Active? %@", (motionManager.gyroActive ? @"YES" : @"NO"));
}
输出是
2011-09-29 16:37:08.070 Gyro2[4014:607] Gyro Available? YES
2011-09-29 16:37:08.074 Gyro2[4014:607] Gyro Active? NO
我不明白为什么,当我开始更新陀螺仪时,它实际上并没有启动。
【问题讨论】:
-
对不起伙计们,我不确定问题出在哪里,但我只是重写了测试项目并且它成功了。我基于此网站的代码:cs491f10.wordpress.com/2010/10/28/core-motion-gyroscope-example