1

I have the following view hierarchy: view controller A -> popover segue -> navigation controller -> view controller B -> UIImagePickerController

Within the View controller B popover, I use the following code to present the UIImagePickerController:

picker = UIImagePickerController()
picker!.allowsEditing = false
picker!.sourceType = .photoLibrary
picker!.mediaTypes = [kUTTypeMovie as String]
picker!.isModalInPopover = true
picker!.modalPresentationStyle = .currentContext
picker!.delegate = self
present(photoLibraryPickerController!, animated: true, completion: nil)

When the user taps "cancel", I want to dismiss both the image picker and view controller B popovers, and go straight back to view controller A. Here is my code to do this:

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
    picker!.dismiss(animated: false, completion: nil)
    dismiss(animated: false, completion: nil)
}

This effectively dismisses both the image picker and view controller B, but there is a brief delay after the image picker is dismissed. So you can see view controller B on the screen for a moment before it is then dismissed.

How can I dismiss both view controllers simultaneously to avoid this flashing?

RGold
  • 21
  • 4
  • There are quite a few approaches to the solution here: https://stackoverflow.com/questions/2944191/iphone-dismiss-multiple-viewcontrollers I would suggest the snapshot approach using the root view controller's window to overlay a "mocked" subview on view controller A while the other view controllers are dismissed. – Eric Armstrong Mar 18 '18 at 15:57

0 Answers0