SDWebImage清除缓存 [英] SDWebImage clearing cache
问题描述
我正在显示从网络下载的图标列表,其中包含表格视图中的文本。可以在服务器端更改图标,我需要在新图标可用时立即更换它们。我尝试使用以下代码:
I'm displaying a list of icons downloaded from the web with text in a table view. The icons can be changed on server side and I need to replace them as soon as new icons are getting available. I try using the following code:
[imgView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"table_avatar_icon"] options:SDWebImageCacheMemoryOnly];
并调用 [[SDImageCache sharedImageCache] clearMemory];
在我的刷新回调中,但它不会清除缓存的内容。更重要的是,即使我关闭应用程序并再次打开它,图像仍然存在。
And call [[SDImageCache sharedImageCache] clearMemory];
In my refresh callback, but it does not purge the contents of the cache. More to it, even if I close the application and open it again the image is still there.
我发现只有一种方法可以清除缓存,而是通过调用 [[SDImageCache sharedImageCache] clearDisk];
。这只有在我关闭并重新打开应用程序后才有效。
I found only one way to clear the cache and it is by calling [[SDImageCache sharedImageCache] clearDisk];
. Which only works after I close and reopen the app.
如何强制SDWebImage不使用磁盘缓存?
How can I force SDWebImage to not to use disk caching?
推荐答案
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache clearMemory];
[imageCache clearDisk];
不要忘记将这些代码行放在 didReceiveMemoryWarning中
,也是。
Don't forget to put these lines of code in your didReceiveMemoryWarning
, too.
这篇关于SDWebImage清除缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!