如何清除从 SDWebImage 加载的所有缓存图像? [英] How to clear all cached images loaded from SDWebImage?
本文介绍了如何清除从 SDWebImage 加载的所有缓存图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已通过 SDWebImage 将所有图像加载到我的应用程序中.下载和缓存效果很好,但我想制作一个按钮,可以清除整个应用程序中的所有缓存图像.
I have all images loaded on my app via SDWebImage. The downloading and caching works great, but I wanted to make a button that can clear all cached images in the entire app.
我的一个标签栏视图上有一个清除缓存"按钮作为 UIButton.我怎样才能让点击这个按钮时,所有缓存的图片都被删除,需要重新下载?
I have a "Clear Cache" button as a UIButton on one of my tab bar views. How can I make it so when this button is tapped, all the cached images are removed and need to be re-downloaded?
使用 Swift.
谢谢!
推荐答案
如果您想完全清除缓存,请执行以下操作:
If you want to completely clear the cache do the following:
- (IBAction)clearCache:(id)sender {
[[SDImageCache sharedImageCache]clearMemory];
[[SDImageCache sharedImageCache]clearDisk];
}
斯威夫特 5
SDImageCache.shared.clearMemory()
SDImageCache.shared.clearDisk()
斯威夫特 3.0
@IBAction func clearCache(sender: UIButton) {
SDImageCache.shared().clearMemory()
SDImageCache.shared().clearDisk()
}
这篇关于如何清除从 SDWebImage 加载的所有缓存图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文