当从服务器下载图像和填充集合视图(电网3 * N)。我正在发生故障。的iOS - 的CollectionView图像消失上滚动和有时重叠
我几乎尝试了一切可能像重用细胞,并使用GCD从主线程更新图像视图之前使图像视图为零。
但我仍然面临着小故障。
毛刺是,当我滚动集合视图,下载重叠,有时图像从集合视图细胞消失。
我不知道是什么原因造成的图像消失(这曾经下载)。
任何建议。
private func cellForDropbox(cell:GridCell,indexPath:IndexPath) -> GridCell {
let filename = self.filenames[(indexPath as NSIndexPath).row]
cell.imageView.backgroundColor = UIColor.lightGray
cell.imageView.image = nil
DropboxClientsManager.authorizedClient?.files.getTemporaryLink(path: filename).response(completionHandler: { (response, error) in
if let url = response {
cell.imageView.sd_setImage(with: URL(string:url.link), placeholderImage: nil, options: .refreshCached, completed: { (img, error, cacheType, url) in
})
} else {
print("Error downloading file from Dropbox: \(error!)")
}
})
return cell
}
你为什么要救图像在缓存中。如果你已经使用SDwebImage。 – KKRocks
@KKRocks:抱歉,现在删除,你有这个想法? – user3804063