我的 segue 在 imagepicker 中不起作用
my segue is not working in imagepicker
我有一个 UIImagePickerController
所以当用户选择 his/her 照片时,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")
}
我得到 "image loaded" 和 "segue loaded" 但我的 viewcontroller 仍然是以前的
尝试在 dismiss
的完成块中 performSegue
当你关闭 UIImagePickerController
时。
self.dismiss(animated: true) {
performSegue(withIdentifier: "ToPrescriptionView", sender: nil)
}
我有一个 UIImagePickerController
所以当用户选择 his/her 照片时,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")
}
我得到 "image loaded" 和 "segue loaded" 但我的 viewcontroller 仍然是以前的
尝试在 dismiss
的完成块中 performSegue
当你关闭 UIImagePickerController
时。
self.dismiss(animated: true) {
performSegue(withIdentifier: "ToPrescriptionView", sender: nil)
}