将图片转至下一张 ViewController (Swift)

Segue Image to next ViewController (Swift)

我正在尝试将 Cached/Downloaded 图像传递到我的显示视图控制器,该控制器将与不同的图像进行连接。我可以下载图像并将其设置为我当前控制器上的 UIImageView,或者如果我手动下载一个 UIImage 图像,我可以在将它分配给 ImageStore 变量时继续它。然而,当通过 cache/download 方法下载我的图像时,它作为 UIImageView 到达,我如何将它作为变量传递给另一个控制器?

@IBOutlet weak var Image1: UIImageView!



var ImageStore: UIImage!//transfer image code to next screen
var ImageStore: UIImage!//transfer image code to next screen

@IBAction func Chart1Click(_ sender: Any)//chart 1
{
    performSegue(withIdentifier: "Chart1", sender: nil)
}

@IBAction func Chart2Click(_ sender: Any)//chart 2
{
    performSegue(withIdentifier: "Chart2", sender: nil)
}

@IBAction func Button(_ sender: Any)//download charts
{
    Image1.sd_setImage(with: URL(string: "https://www.vedur.is/photos/flugkort/PGDE14_EGRR_0000.png"), placeholderImage: UIImage(named: "placeholder.png"))
 //assing the Image1 to ImageStore ??

//more downloaded here
}


override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
    if (segue.identifier == "Chart1")
    {
        let destinationViewController = segue.destination as! ChartAController
        destinationViewController.TransferImage = ImageStore
        print("Chart 1 Segue")
    }
    if (segue.identifier == "Chart2")
    {
        let destinationViewController = segue.destination as! ChartAController
        destinationViewController.TransferImage = ImageStore2
        print("Chart 2 Segue")
    }
}

直接发送

ImageStore.image

应该可以解决问题。如果你想发送图像而不是 imageView.