gpt4 book ai didi

ios - Swift UIImageView 始终为空

转载 作者:行者123 更新时间:2023-11-30 12:43:31 29 4
gpt4 key购买 nike

我的 UIImageView 始终是空白的。加载 ImageView 后,我让它打印图像和 ImageView 。这是代码第一部分中打印的输出:UIImage: 0x170898010>, {4032, 3024}UIImageView:0x14bb077e0; frame = (0 64; 375 554); 这是代码第二部分中打印的输出: autoresize = RM+BM;用户交互启用=否; layer = CALayer: 0x170a31240 似乎正在存储图像,但没有出现。

这里是正确保存到 CloudKit 的图像的下载和转换位置:

if let asset = record["Picture"] as? CKAsset,
let data = NSData(contentsOf: asset.fileURL),
let image1 = UIImage(data: data as Data)
{
let eventPageViewController:EventPageViewController = self.storyboard?.instantiateViewController(withIdentifier: "EventPage") as! EventPageViewController
eventPageViewController.toPass = image1
print(image1)
}

下面是显示 UIImageView 的 ViewController 的代码:

class EventPageViewController: UIViewController {
@IBOutlet weak var eventPic: UIImageView!
var toPass: UIImage!

override func viewDidLoad() {
super.viewDidLoad()

eventPic.image = toPass
print(eventPic)
}

这里是 eventPageViewController 出现的位置:

func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

let eventPageViewController:EventPageViewController = storyboard?.instantiateViewController(withIdentifier: "EventPage") as! EventPageViewController

self.present(eventPageViewController, animated: true, completion: nil)
}

最佳答案

来自有关图像属性的 Apple 文档:

This property is set to the image you specified at initialization time. If you did not use the init(image:) or init(image:highlightedImage:) method to initialize your image view, the initial value of this property is nil.

https://developer.apple.com/reference/uikit/uiimageview/1621069-image

关于ios - Swift UIImageView 始终为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41946471/

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