Midhun Narayan
Midhun Narayan

Reputation: 879

While picking image using image picker if i tap multiple times my viewcontroller also dismissing

While selecting image using image picker if i select multiple times (double tap on image) after dismissing the image picker my view controller also getting dismissed

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    let selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage
    userImage.image = selectedImage
    dismiss(animated: true, completion: nil)
}

how to restrict the code not to dismiss my view controller while double tapping the image. Need to dismiss the image picker controller only

Upvotes: 1

Views: 748

Answers (1)

JAHID HASAN POLASH
JAHID HASAN POLASH

Reputation: 191

The problem here is that dismiss() method is calling the viewController object to dismiss. you have to specify which one to dismiss. use: picker.dismiss(animated: true, completion: nil)

Upvotes: 2

Related Questions