[英]How to know image has been downloaded in SDWebImage
Currently I am integrating SDWebImage in my project, 目前,我正在将SDWebImage集成到我的项目中,
1) #import "UIButton+WebCache.h"
1) #import "UIButton+WebCache.h"
2) [button setImageWithURL:url placeholderImage:[UIImage imageNamed:@"no_photo.png"]];
2) [button setImageWithURL:url placeholderImage:[UIImage imageNamed:@"no_photo.png"]];
Now I want to know when the image is downloaded successfully or not, How can I know this? 现在我想知道何时成功下载映像,我怎么知道呢?
You can do this using the setImageWithURL:
method and blocks like so: 您可以使用setImageWithURL:
方法和如下代码块来执行此操作:
Start your downloading animation. 开始下载动画。 Then use this to download the image into an image view (or button, as you seem to be doing that above). 然后使用它将图像下载到图像视图(或按钮,就像您在上面所做的那样)。
[imageView setImageWithURL:[NSURL URLWithString:imageURL]
placeholderImage:[UIImage imageNamed:@"YourPlaceholder.png"]
success:^(UIImage *image) {
// remove animation
}
failure:^(NSError *error) {
NSLog(@"thumbnail error: %@",error);
// handle failed download
}];
try this for latest version of SDWebImageManager 试试这个以获得最新版本的SDWebImageManager
/**
* Check if image has already been cached
*/
- (BOOL)diskImageExistsForURL:(NSURL *)url;
在项目中搜索memcache setObject
,下载后此行将图像存储在缓存中。在此行之后,您可以发布通知并在您自己的类中检查它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.