Xcode:SDWebImage 清除单个图像的缓存 [英] Xcode: SDWebImage clear cache for single image

查看:33
本文介绍了Xcode:SDWebImage 清除单个图像的缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SDWebImage 来支持缓存的异步图像下载器.

I'm using SDWebImage to asynchronous image downloader with cache support.

它工作得很好,只是有时图像在服务器上以相同的名称更新,因此我需要从客户端设备缓存中清除它但没有成功!

It's working perfectly except that sometimes the image got updated on the server with same name, thus I need to clear it from client device cache but no success!

我在此处发现我必须使用removeImageForKey",但 Xcode 无法识别它!

I found here that I have to use "removeImageForKey" but it's not recognized by Xcode!

我使用以下代码来设置图像:

I'm using the following code to set the image:

[imgPic setImageWithURL:[NSURL URLWithString:@"http://domain.com/image.jpg"] placeholderImage:[UIImage imageNamed:@"tmpPic.png"]];

调用 removeImageForKey 的正确方法是什么?我必须导入什么而不是 UIImageView+WebCache.h?

What's the correct way to call removeImageForKey? What do I have to import rather than UIImageView+WebCache.h?

推荐答案

- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk;

API 是对的.它对我有用.你知道 api 在类 SDImageCache 中,它是一个单例类.
你可以这样使用它:

API is right. It work for me. Do you know the api is in class SDImageCache which is a singleton class.
You could use it like this:

[[SDImageCache sharedImageCache] removeImageForKey:image_url fromDisk:YES];

这篇关于Xcode:SDWebImage 清除单个图像的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆