从屏幕锁返回后,如何重新启动设备运动



我在iOS 7中发现了一个问题,该问题经常发生但并非总是如此。

首先,我以这样的方式设置了设备运动:

[self.motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryCorrectedZVertical
                                                               toQueue:[NSOperationQueue currentQueue]
                                                           withHandler:motionHandler];

用户使用iOS 7锁定iPad mini上的屏幕。当用户再次等待5秒钟之前,他再次解锁屏幕时,设备运动再次工作正常。

当用户锁定后快速解锁屏幕时,设备运动停止工作,处理程序不再调用。

我假设在这种情况下,程序员必须手动重新启动设备运动。保证设备运动成功运行的推荐方法是什么?

尝试从AppDelegate

覆盖这些方法

- (void)applicationwillresignactive:(uiapplication *)应用程序

- (void)applicationwillenterforeground :( uiapplication *)应用程序

- (void)applicationDidBecomeycomeTive:(uiapplication *)应用程序

gl hf

最新更新