问题:
我在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions加入锁屏的代码
// 阻止锁屏
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
但是当进入照相界面,再退出照相。 阻止锁屏功能无效了。
// 进入照相
[self presentViewController:imagePicker animated:YES completion:nil];...
// 退出
[self dismissViewControllerAnimated:YES completion:nil];
解决方案:
在-(void)viewWillAppear:(BOOL)animated里面添加
// 阻止锁屏
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];