I have an app where I present a UIImagePickerController
with source type UIImagePickerControllerSourceTypeCamera
. Everything works fine unless I leave the app and come back (multitasking is enabled so the app comes back right where it left off) and I present the UIImagePickerController
again. It appears on screen but the camera never shows, the animation where the camera is revealed never happens, here is a screenshot:
If I press cancel and present the UIImagePickerController
again, the camera will show up fine. So the only time this problem occurs is the first time I present the UIImagePickerController
after coming back to the app. Anyone know why this is happening? I'm coding for iOS 5
I'm presenting the UIImagePickerController
with:
[self presentViewController:capturePhotoPicker animated:YES completion:nil];
and dismissing it with:
[self dismissViewControllerAnimated:YES completion:nil];
I am using the same UIImagePickerController
object each time I present it
I had exactly the same problem and then realized I wasn't releasing the
UIImagePickerController
after presenting it. The camera now works fine first-time after leaving and returning to the app.So this is my exact code:
It's one of those problems you can spend ages on, and the solution is not that obvious (well, it wasn't to me), so I hope this helps some people!
if you change the -(void)viewDidLoad to - (void)viewDidAppear:(BOOL)animated it fixes the problem. I've spent the last 2 weeks trying to figure this out