The same thing happened to me after locking / unlocking the application, it seems that the shutter opens on viewDidAppear.
So, I subscribed my parent view controller to UIApplicationDidBecomeActiveNotification and manually re-executed the viewWillAppear and viewDidAppear methods of the controller containing the UIImagePickerController
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; . . . - (void)applicationBecomeActive { if (imagePicker_) [imagePicker_ openShutter]; }
And then on the controller containing the UIImagePickerController
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [imagePickerController_ viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [imagePickerController_ viewDidAppear:animated]; imagePickerController_.cameraFlashMode = cameraFlashMode_; imagePickerController_.cameraDevice = cameraDevice_; } - (void)openShutter { [imagePickerController_ viewWillAppear:YES]; [imagePickerController_ viewDidAppear:YES]; }
PS: If you try this, do not forget to remove the observer
[[NSNotificationCenter defaultCenter] removeObserver:self];
Hope this helps
source share