所以我有什么:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info:[String : Any]) {
let tempImage: UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage
let imagetoTransmit: UIImage = tempImage
shootedImage = imagetoTransmit
self.performSegue(withIdentifier: "cameraSegueIdent", sender: nil)
dismiss(animated: true, completion: nil)
}
哪里转:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "cameraSegueIdent" {
let imageToTransmit: UIImage = shootedImage
let viewController = (segue.destination as! TakenPhotoPreviewViewController)
viewController.takenImage = imageToTransmit
}
}
图像正在发送,但 Segue 没有执行。
请帮助!
更新
我的想法是将图像作为发送者发送,而不保存在当前的 ViewController 中,它就像一个魅力!
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info:[String : Any]) {
let tempImage: UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage
self.dismiss(animated: true) {
self.performSegue(withIdentifier: "cameraSegueIdent", sender: tempImage)
}
}
以下可能会有所帮助。
let tempImage: UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage
let imagetoTransmit: UIImage = tempImage
shootedImage = imagetoTransmit
_ picker.dismissViewControllerAnimated(true, completion: {
self.performSegue(withIdentifier: "cameraSegueIdent", sender: nil)
})
另外,请确保在 Storyboard中正确配置了 segue 标识符。
关于ios - 如何使用 Segue 从 didFinishPickingMediaWithInfo 发送 UIImage?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39919866/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |