I was able to reset the UIApplication idleTimerDisabled like so:
- (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];
}];
}
What I suspect is happening is that internally UIImagePickerController
sets UIApplication.idleTimerDisabled
to YES
to keep the camera from sleeping. When finished (after the delegate methods are called and apparently even after the animation completion block is executed), the UIImagePickerController
sets UIApplication.idleTimerDisabled
back to NO
. Instead, it only should do this if the value was previously NO
.
I filed a bug report with Apple. See UIImageViewControllerBug sample project.