Reputation: 354
I am developing an app where I have to use the image picker controller to import an image from the library of the phone. The problem is I have first to dismiss the picker controller then present another controller after the picker controller dismisses. Is there a way where I do not have to dismiss the image picker controller, but instead present a view controller or a nav controller. By the way, if I do not dismiss the imagePickerController, it will crash. Second, I am presenting a view controller that passes the image that was selected. Thank you.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let shViewController = SHViewController()
if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
shViewController.image = editedImage
} else if let originalImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
shViewController.image = originalImage
}
shViewController.delegate = self
dismiss(animated: true, completion: nil)
present(shViewController, animated: true, completion: nil)
}
Upvotes: 0
Views: 600
Reputation: 100503
You can't present 2 vc from the same vc , so either
picker.present(shViewController, animated: true, completion: nil)
OR
dismiss(animated:false) {
self.present(shViewController, animated: true, completion: nil)
}
Upvotes: 1