我正在使用 Kingfisher 下载图像并将其设置为 UITableView 单元格中的图像视图。一切正常,表格视图在下载新图像之前首先显示占位符图像。然而,这些占位符图像只有在我滚动表格视图后才会更新为正确的图像。图像下载后如何立即更新单元格?谢谢你。
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
}