gpt4 book ai didi

ios - 如何使用 Segue 从 didFinishPickingMediaWithInfo 发送 UIImage?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:56:59 25 4
gpt4 key购买 nike

所以我有:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com