【发布时间】:2012-12-10 21:20:50
【问题描述】:
我有这个奇怪的问题。在我的应用程序中,我询问设备,DeviceMotion 是否可用:
if (coreMotionManager.isDeviceMotionAvailable) {
coreMotionManager.deviceMotionUpdateInterval = 1.0 / 60.0;
[coreMotionManager startDeviceMotionUpdates];
[NSTimer scheduledTimerWithTimeInterval:1.0 / 60.0 target:self selector:@selector(didUpdateCoreMotion) userInfo:nil repeats:YES];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"NO DEVICE MOTION" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
但它总是错误的...... 我究竟做错了什么?我在我的 iPad 3 上执行此操作,过去我已经使用过 CMMotionManager 以及它的 .deviceMotion.attitude.roll、pitch 和 yaw,一切都很好。但是现在我总是很警觉o.O
有没有人知道可能出了什么问题?非常感谢您的帮助:)
终于重启了我的Mac,重启后一切正常! :) 感谢 Kay 的支持和帮助 :)
【问题讨论】:
-
什么意思?不可能通过 Xcode 运行超过 1 个应用程序实例,是吗?无论如何,杀死该应用程序无济于事:(
-
CMMotionManager 的 2 个实例:重要提示:应用应仅创建 CMMotionManager 的单个实例
-
在我的应用程序中,只有 2 个 ViewController 使用“this Core”数据,一个使用 LocationManager,另一个使用 MotionManager。我想这两个不会互相干扰。回到你的评论,不,我创建 CMMotion manager od setup (init) 并在 viewDidUnload 方法中将其设置为 nil
-
你能试试gyroAvailable是否工作以及对应的accelerometerAvailable吗?您是否有任何工具来验证硬件是否正常运行,例如Xcode 示例 MotionGraphs 或 SensorMonitor?
标签: objective-c ios ipad gyroscope core-motion