我正在使用 SDWebImage 库进行缓存和延迟加载。但我发现有时它会显示另一个单元格的图像。
细节场景
- 有 CollectionView 具有包含 UIImageView 和标签的单元格。
- ImageView 包含用户的图像和带有他们
名称的标签。
但有时 Imageview 中加载的 Image 会有不同的图像。
让我们说
Index Name Image
0 nameA A
1 nameB B
2 nameC C
3 nameD B
所以这里因为索引有nameD所以图像应该是b“D”但它显示的是nameB的图像,即“B”
这是我使用的代码
if ([aMutDict objectForKey:@"picture_url"])
{
[[SDWebImageManager sharedManager]downloadWithURL:[NSURL URLWithString:[aMutDict objectForKey:@"picture_url"]] options:SDWebImageProgressiveDownload progress:Nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
if(image){
[cell.imgProfilePic setImage:image];
}else{
[cell.imgProfilePic setImage:ApplicationDelegate.gblImgPlaceholder];
}
}];
}