gpt4 book ai didi

ios - 以编程方式快速加载图像

转载 作者:搜寻专家 更新时间:2023-10-30 22:22:10 26 4
gpt4 key购买 nike

我有一个 ImageView。这是我用来将图像添加到 ImageView 的代码

 var imgstr = pf["ImageFileName"] as String
image = UIImage(named: imgstr)!
println(imgstr) //the output here is abc.png
self.Imageview.image = image

现在我的项目文件夹中有了图像,您可以在屏幕截图中看到 Screenshot

我仍然在运行时遇到这个错误

fatal error: unexpectedly found nil while unwrapping an Optional value

最佳答案

将您的图像添加到 Images.xcassets

enter image description here

imageView.image = UIImage(named:"abc")

关于ios - 以编程方式快速加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29789748/

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