[英]SDWebImage caching is taking time to load the image from cache in uicollectionview cell
[英]SDWebImage not returning correct image UICollectionView for first time
我有一個SDWebImage
版本3.7.3,在其中使用sd_setImageWithURL:placeholderImage:options:completed:
每當下載實際圖像時,我第一次嘗試從collectionview加載時,它將顯示其他一些單元格圖像。 下載完成后,其工作正常。 任何解決此問題並顯示占位符圖像的方法。
我已經在prepareForReuse
嘗試了幾種解決方案sd_cancelimagerequest
並設置了imageview.image = nil
並在主線程上進行了設置,但是它們似乎都不起作用。
在您的- collectionView:cellForItemAtIndexPath:
,在調用sd_setImageWithURL:
之前在您的單元格sd_setImageWithURL:
UIImage
設置為nil。
很有可能collectionView
會重新使用舊單元,以最大程度地降低性能影響。
將- collectionView:cellForItemAtIndexPath:
的圖像重置為nil - collectionView:cellForItemAtIndexPath:
如果您在完全關閉的(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL)
,則應檢查imageURL參數是否等於單元格所需的真實URL
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.