【发布时间】:2015-12-03 11:44:51
【问题描述】:
我正在使用SDWebImage 库来处理图像缓存。我实现了一种从服务器下载图像并在tableView 中填充数据的方法。这是我下载图像并在tableViewCell 中显示的代码
在cellForRowAtIndexPath,我做了如下代码
[cell.profileImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil options:SDWebImageRefreshCached];
在这里完美运行。但是当我在服务器上更新图像时,tableViewCell 仍然显示相同的图像。问题是,它的缓存没有更新图像。我用相同的关键字搜索,在 StackOverflow 上遇到了this 问题。但无法解决问题。我还尝试清除viewDidDisappear上的内存和缓存
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:YES];
[[SDImageCache sharedImageCache]clearMemory];
[[SDImageCache sharedImageCache]clearDisk];
}
但它不是有效的方法。更新服务器上的图像时,还有其他方法可以更新缓存吗?
【问题讨论】:
-
有没有办法知道图片是否更新了?
-
尝试使用这个[[SDImageCache sharedImageCache]imageCache clearMemory]; [[SDImageCache sharedImageCache]imageCache clearDisk];
-
@EktaMakadiya,每次清除缓存都会从服务器重新加载数据。它忽略了 SDWebImage 的使用。
-
如果你的 url 是静态的,那么不要缓存图片。每次重新加载图像。因为缓存的意思是存储图片以备后用。
标签: ios objective-c sdwebimage image-caching