我试图将图像发送到另一个视图控制器。
override func prepare(for segue: UIStoryboardSegue, sender: Any!) {
if (segue.identifier == "cropSegue") {
let crop : CropViewController = segue.destination as! CropViewController
crop.cropImage = image
print("prepared")
}
}
并在接收端
class CropViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
var cropImage : UIImage!
override func viewDidLoad() {
super.viewDidLoad()
self.imageView.image = cropImage
// Do any additional setup after loading the view.
}
我不确定出了什么问题,但是图像没有被显示,甚至认为正在调用segue的准备工作。关于为什么的任何想法?
答案 0 :(得分:0)
试试这个
class CropViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
var cropImage : UIImage?
override func viewDidLoad() {
super.viewDidLoad()
if let image = cropImage {
self.imageView.image = image
}
}