CMDeviceMotion 不提供态度信息
由于某种原因,我的 iPad2 不提供运动姿态信息。我正在做据我所知正是人们所说的事情,但仍然......没有数据。
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];
}
但是我从来没有得到角度。帮助?
For some reason my iPad2 is not providing motion attitude information. I am doing AFAIK precisely what people say to do but still... no data.
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.");
}
Earlier in my code I do this:
motionManager = [[CMMotionManager alloc] init];
if (motionManager.gyroAvailable) {
[motionManager startGyroUpdates];
}
However I never get the angle. Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用initialisaiton:和
stopDeviceMotionUpdates
。如果您使用设备运动更新,您只会获得态度,即您必须在进入后台时
You only get attitude if you use device motion updates, i.e. you have to call for initialisaiton:
And
stopDeviceMotionUpdates
when going to background.