我正在使用Kingfisher在UITableView的单元格中下载图像并将其设置为imageviews。一切正常,在下载新图像之前,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
}
答案 0 :(得分:0)
您可以从表格视图中获得可见的单元格,在那里您可以获取每个单元格的图像视图。您可以尝试使用翠鸟来更新图像。在这里,您没有刷新单元格。查找单元并更新内容。这样,它看起来就不会闪烁。