Reputation: 2032
I have an application which uses a UIImagePickerView to allow the user to either take a picture with their camera or select one from the camera roll using the UIImagePickerView.
After getting a picture, I present a different dialog on top of the picker using [picker presentViewController:myViewController animated:YES completion:nil]
.
If I run my app as an iPhone app (on my iPad), when I dismiss myViewController
using [myviewController.presentingViewController dismissViewControllerAnimated:YES completion:nil]
it goes back to either showing the CameraRoll or the CameraFeed to take another picture.
But on the iPad, if I am selecting a picture, it works, but if I am taking a picture using the camera feed, I just get a black screen.
Any idea why?
Upvotes: 6
Views: 1807
Reputation: 1177
On iPad when you are using sources different than camera feed, you are presenting UIImagePickerController in a popover and you can use it as long as you wish. But when you decide to pick up the source UIImagePickerControllerSourceTypeCamera
the picker window is presenting full screen and you have two cases:
Apple docs for imagePickerController:didFinishPickingMediaWithInfo:
:
If you set the image picker’s showsCameraControls property to NO and provide your own custom controls, you can take multiple pictures before dismissing the image picker interface. However, if you set that property to YES, your delegate must dismiss the image picker interface after the user takes one picture or cancels the operation.
If you want to take another picture in this case you have to go back to your base controller and create the UIImagePickerController instance one more.
I hope this will help.
Edit: The easiest way IMO to rebuild your view controllers stack is to dismiss the picker after taking a photo without animation and after that show the next controller with animation. It will give the user feeling, that the next controller is displayed just after the picker controller without any "flashing".
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissViewControllerAnimated:NO completion:^{
[self presentViewController:<newController> animated:YES completion:nil];
}];
}
Upvotes: 6
Reputation: 16482
I had a similar problem in an app. I ended up presenting the image picker for the camera in a popover controller rather than modally for iPad. I'm not sure if this will work for your app but that's a different approach. I had no problems doing it this way and liked it much better.
Upvotes: 1
Reputation: 3527
You can try dismiss normally the UIImagePicker, and when the Pre-viwer View Controller activate viewWillDesapear, you "say" to the previous viewController that when it viewWillAppear, it shows the UIImagePicker again. I think that it works.
Upvotes: 1