CMMotionManager does not create any .deviceMotions

I am working on an AR application for my company, and it runs smoothly, with the exception of one in ten devices. (all iphone 4 and 4s, 5.1.1 +)

When we run this code:

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

We get a solid block “Device movement is active, but the device is not received on some devices”, but it seems completely random.

If motionManager.deviceMotionActive true and a motion manager exists, .deviceMotion should return CMDeviceMotion. But it just returns zero.

Does anyone have any ideas what might cause this? Check is done in my

 - (void)onDisplayLink:(id)sender 
+8
objective-c iphone augmented-reality cmmotionmanager
source share
2 answers

After some roaming, we found that this was due to an infrequent hardware / firmware error. The wisest thing is to check that motionManager.deviceMotion is Nil and motionManager.deviceMotionActive is true.

+5
source share

To call

 [motionManager startDeviceMotionUpdatesUsingReferenceFrame:someFrame]; 

or

 [motionManager startDeviceMotionUpdates]; 

to start the update and periodically access the CMDeviceMotion objects by reading the deviceMotion property.

-one
source share

All Articles