Is there a UIImagePickerController replacement tha

2019-08-24 03:21发布

问题:

I'm writing an app that uses UIImagePickerController to let the user choose images from their library. On the iPad, it shows it in a popover (because you must) but the controller which is showing it is already in a popover, and you're not allowed to show a popover from another popover. I can't rework the whole app to avoid the files controller being in a popover, so what I'd like to do is to push the image picker onto the files controller's navigation stack.

Obviously this isn't going to work with the stock image picker, but there are a lot of alternatives. Has anyone used any of them that would let me push them onto the navigation stack, or do I need to write my own?

回答1:

The proper solution is to present the image picker as a modal view controller to your existing view controller. Set the image picker's modalPresentationStyle to UIModalPresentationCurrentContext.

This will show the image picker in the same popover but as a modal view controller over the calling view controller.