Search code examples
swiftuiimageviewuiimagepickercontrollerswift5

UIImagePickerController - Confirmation View (similar to allowsEditing = true)


I have an image picker program using UIImagePickerController.

I noticed when I set allowsEditing to true, i.e.

imagePicker.allowsEditing = true

It creates a nice overlay with a crop box, and lets me make edits before I choose.

I want to use full screen (no cropping), so I went ahead and set allowsEditing to false

Now when I pick an image, it immediately chooses it and fires

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) 

Which isn't helpful because it doesn't give the user a chance to preview the image before uploading it - it just fires and my program then takes it as input and displays in the user's feed / uploads to my image store in Amazon S3.

Is there a way to somehow utilize the "intercept / preview" feature of the "allowsEditing = true" aspect of the image picker to show a preview screen to let the user confirm/cancel their image before moving forward?

I know I could create it myself but I fear I need to add some custom buttons and a custom screen, wasn't sure if maybe there was a creative or out of the box way to do this automatically.

..For example I set allows edit to true, and somehow make the crop bounding box invisible or something like that.

Thank you very much for your time and suggestions!


Solution

  • If you are choosing a photo from the user’s library, then no, you cannot interpose a confirmation within the picker, because choosing a photo dismisses immediately.

    You should just write an independent intervening confirmation dialog after dismissal and before you proceed with the networking step.