本文介绍了图像加载需要更多时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个应用程序,其中正在从服务器加载一些图像,并使用Alamofire将其显示在表格视图上。但是问题在于加载图像需要花费大量时间。我想显示图像,就像模糊的图像,直到未加载时间图像。
I am working on an application, where I am loading some images from the server and showing it on table view using Alamofire. But the problem is it is taking so much time to load the image. I want to show the image, like a blurry image until the time image is not loading. Please, someone, help me.
cell.profileImageView?.pin_setImage(from: URL(string: modelArray[indexPath.row]))
推荐答案
这是使用吊舱。您可以在加载图像时设置活动指示器。
This one is the solution using Kingfisher pod. You can set an activity Indicator while image is loaded.
let imageUrl = modelArray[indexPath.row]
//set activity indicator until image is loaded
cell.profileImageView?.kf.indicatorType = .activity
if let url = URL(string: imageUrl) {
let resource = ImageResource(downloadURL: url)
cell.profileImageView?.kf.setImage(with: resource)
}
这篇关于图像加载需要更多时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!