我有一个iPad调查工具作为内部企业应用程序.我通过设置[[UIApplication sharedApplication] setIdleTimerDisabled:YES]来防止屏幕锁定;在didFinishLaunchingWithOptions的应用程序委托.
直到我使用imagePicker拍摄图像才能正常工作.之后,再次激活idleTimer.我尝试在拍摄图像后禁用它,但不起作用.
Here我发现在info.plist中设置所需设备功能的提示可能有所帮助.但到目前为止还没有.我刚添加了所有相机标志.
有任何想法吗?
非常感谢!
马库斯
解决方法
我可以像这样重置UIApplication idleTimerDisabled:
- (void)resetIdleTimerDisabled { [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; } #pragma mark - UIImagePickerControllerDelegate - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissViewControllerAnimated:YES completion:^{ [self performSelector:@selector(resetIdleTimerDisabled) withObject:nil afterDelay:1.0]; }]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { [self dismissViewControllerAnimated:YES completion:^{ [self performSelector:@selector(resetIdleTimerDisabled) withObject:nil afterDelay:1.0]; }]; }
我怀疑发生的是,内部UIImagePickerController将UIApplication.idleTimerDisabled设置为YES,以防止相机进入睡眠状态.完成后(在委托方法被调用后,即使在执行动画完成块之后显然),UIImagePickerController将UIApplication.idleTimerDisabled设置为NO.相反,如果该值以前是NO,则应该这样做.
我向苹果提交了一个错误报告.见UIImageViewControllerBug示例项目.