2012-09-28 28 views
8

我正在为我公司的AR应用程序工作,并且它工作正常,除了十个设备中的大约一个。 (所有的iPhone 4和4S,5.1.1+)CMMotionManager不生产任何.deviceMotions

当我们运行这段代码:

CMDeviceMotion *d = motionManager.deviceMotion; 

    if (d == nil && motionManager.deviceMotionActive && motionManager != nil) { 
     DLog(@"Device motion is active, but no device motion recieved"); 
    } 

我们对一些获得的“设备运动是积极的,但没有设备运动收到”固体块这些设备,但它似乎完全随机。

如果motionManager.deviceMotionActive为真,且存在运动管理器,则.deviceMotion应返回CMDeviceMotion。但它只是返回零。

有没有人有一个想法可能会导致这种情况?该检查是在我

- (void)onDisplayLink:(id)sender 
+0

在iphone 4和4s中都可以找到bug的设备。 –

+0

您是否尝试过检查对象内存分配/释放。可能会有问题。另请查看此链接:http://iphonedevsdk.com/forum/iphone-sdk-development/103541-cmdevicemotion-flick-gesture.html – iCreative

+0

使用基于块的方法时,您是否遇到同样的问题? – Jonathan

回答

5

经过一番漫游之后,我们发现这是由于罕见的硬件/固件错误。最明智的做法是检查motionManager.deviceMotion是否为零,并且motionManager.deviceMotionActive为true。

+1

真是一个惊喜....另一个苹果的错误。很抱歉听到你浪费了很多时间。 – jww

+0

你是如何解决这个问题的?我面临同样的问题,不知道该怎么做。我发现它并显示警告。有时使用内置的指南针应用程序校准传感器有所帮助,但有时候不会...... – shelll

-1

呼叫正在运行

[motionManager startDeviceMotionUpdatesUsingReferenceFrame:someFrame]; 

[motionManager startDeviceMotionUpdates]; 

方法开始更新,并定期通过读取deviceMotion属性访问CMDeviceMotion对象。