Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 double tap on image dismisses UIImagePickerController and presenter view controller

Tags:

ios

swift

ios11

We have a photo picker made with UIImagePickerController.

When making double tap (instead of one tap) the photo from gallery.

  • On iOS 10: UIImagePickerController is dismissed
  • On iOS 11: UIImagePickerController is dismissed and presenting view controller is dismissed as well :0

Is it iOS 11 bug or we have to adjust something?


Our code:

  let vc = UIImagePickerController()
  vc.delegate = self
  vc.modalPresentationStyle = .overFullScreen
  vc.allowsEditing = false
  rootVC.present(vc, animated: true) // `rootVC` also presented modally.
like image 733
Vlad Avatar asked Dec 13 '22 19:12

Vlad


1 Answers

Instead of self.dismiss(), use picker.dismiss()

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
{
    //self.dismiss(animated: true, completion: nil)
    picker.dismiss(animated: true, completion: nil)
}

This will only dismiss your picker view and not the view controller.

like image 151
kshitiz_7 Avatar answered May 07 '23 16:05

kshitiz_7