我有一个UIImagePickerController
所以当用户选择他/她的照片时会执行segue但是segue无法正常工作(实际上工作但vc未加载)这是我的代码:
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")
}
我正在"图像加载"并且" segue loaded"但我的viewcontroller仍然是前一个
答案 0 :(得分:2)
当您解雇performSegue
时,尝试在dismiss
的完成区内UIImagePickerController
。{/ p>
self.dismiss(animated: true) {
performSegue(withIdentifier: "ToPrescriptionView", sender: nil)
}