未从uiimage视图加载Gif图像(来自url)

问题描述 投票:0回答:1

我正在使用此解决方案:SO。我在哪里从URL加载gif。我的代码如下:

@IBOutlet weak var imageView: UIImageView!

var imageList: [String] = ["http://www.gifbin.com/bin/4802swswsw04.gif", "http://www.gifbin.com/bin/4802swswsw04.gif"]
let imageURL = UIImage.gifImageWithURL(imageList[0])
imageView.image = UIImageView(image: imageURL)

而且我正在使用该This link来支持该SO中提到的gif。但是我收到错误Cannot assign value of type 'UIImageView' to type 'UIImage?。是的,我明白。但是我该如何解决这个问题,我尝试使用UIImage进行修复,但是图像gif没有显示。

任何解决方案都会有帮助。

我什至尝试过:

imageView.image = UIImage.gifImageWithURL(imageList[currentnImageIndex])

但是图像未显示。

ios swift xcode uiimage
1个回答
0
投票

看看错误:Cannot assign value of type 'UIImageView' to type 'UIImage?

您正在创建ImageView,然后将其设置为.image,所以您可能只需要更改:

gifImageView.image = UIImageView(image: imageURL)

gifImageView = UIImageView(image: imageURL)

© www.soinside.com 2019 - 2024. All rights reserved.