[英]Gif image (from url) is not loading in uiimage view
I am using this solution : SO .我正在使用这个解决方案: SO 。 Where i am loading the gif from the url.
我从 url 加载 gif 的地方。 My code look like below :
我的代码如下所示:
@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)
And i am using this This link for gif support as mentioned in that SO.我正在使用这个链接来提供 gif 支持,如该 SO 中所述。 But i am getting error
Cannot assign value of type 'UIImageView' to type 'UIImage?
但我收到错误
Cannot assign value of type 'UIImageView' to type 'UIImage?
. . Yes i understood.
是的,我明白。 But how can i fix this and i tried to fix with UIImage but image gif was not showing.
但是我该如何解决这个问题,我试图用 UIImage 修复,但图像 gif 没有显示。
Any solution would be helpful.任何解决方案都会有所帮助。
I tried even :我什至试过:
imageView.image = UIImage.gifImageWithURL(imageList[currentnImageIndex])
But image was not showing.但图像没有显示。
Take a look at the error: Cannot assign value of type 'UIImageView' to type 'UIImage?
看一下错误:
Cannot assign value of type 'UIImageView' to type 'UIImage?
You're creating an ImageView and then setting it to the .image, so you probably just need to change:您正在创建一个 ImageView,然后将其设置为 .image,因此您可能只需要更改:
gifImageView.image = UIImageView(image: imageURL)
to到
gifImageView = UIImageView(image: imageURL)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.