Reputation:
I have an UIImagePickerController
so when user choose his/her photo the segue is performed but segue is not working ( actually is working but the vc is not loaded ) this is my code:
let imagepicker = UIImagePickerController()
imagepicker.delegate = self
imagepicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
imagepicker.allowsEditing = true
self.present(imagepicker, animated: true)
//...
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
takenimage = info[UIImagePickerControllerOriginalImage] as! UIImage
self.dismiss(animated: true, completion: nil)
print("image loaded")
performSegue(withIdentifier: "ToPrescriptionView", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ToPrescriptionView" {
let PrescriptionView = segue.destination as! Prescription
PrescriptionView.PrescriptionImage = takenimage
print("segue loaded")
}
I'm getting "image loaded" and "segue loaded" but my viewcontroller remains previous one
Upvotes: 2
Views: 172
Reputation: 72410
Try to performSegue
inside completion block of dismiss
when you dismissing UIImagePickerController
.
self.dismiss(animated: true) {
performSegue(withIdentifier: "ToPrescriptionView", sender: nil)
}
Upvotes: 3