gpt4 book ai didi

ios - UITableView 不更新使用 Kingfisher 下载的图像

转载 作者:行者123 更新时间:2023-11-30 11:16:32 25 4
gpt4 key购买 nike

我正在使用 Kingfisher 下载图像并将其设置为 UITableView 单元格中的 ImageView 。一切正常,表格 View 在下载新图像之前首先显示占位符图像。但是,只有在滚动 TableView 后,这些占位符图像才会更新为正确的图像。下载图像后如何立即更新单元格?谢谢。

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = articlesTableView.dequeueReusableCell(withIdentifier: "articleCell", for: indexPath) as! ArticleCell

let resource = self.articlesArray?[indexPath.item].downloadedImageResource
//resources are being downloaded using Kingfisher when populating the articlesArray and added to this array

cell.picView.kf.setImage(with: resource, placeholder: #imageLiteral(resourceName: "LS_logo_male")){ (image, error, cacheType, imageUrl) in
cell.setNeedsLayout()
}


return cell
}

最佳答案

您可以从表格 View 中获取可见单元格,您可以在其中获取每个单元格的 ImageView 。您可以尝试使用 kingfisher 来更新图像。这里你没有刷新单元格。找到单元格并更新内容。这样看起来就不会像闪烁了。

关于ios - UITableView 不更新使用 Kingfisher 下载的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51692419/

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