简体   繁体   English

如何知道图像已在SDWebImage中下载

[英]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.

相关问题 SDWebImage 错误下载的图像有 0 像素 - SDWebImage error downloaded image has 0 pixels 使用 SDWebImage 下载图像,错误 -999(或)SDWebImageErrorDomain Code=0 “下载的图像有 0 像素 - Download image using SDWebImage, error -999 (or) SDWebImageErrorDomain Code=0 "Downloaded image has 0 pixels 如何知道图像是来自SDWebImage中的缓存还是表单URL? - How know whether image is coming from cache or form url in SDWebImage? Twitter是否知道已经下载了哪些消息以及如何下载? - Does Twitter know which message have already been downloaded and how? 如何知道已经使用了哪个注释? - How to know which annoation has been tapped? 如何知道在调用applicationWillEnterForeground或applicationDidBecomeActive时是否已显示启动映像? - How to know whether launch image has been shown when applicationWillEnterForeground or applicationDidBecomeActive is called? 一个特定的应用程序被下载了多少次——这个信息在哪里? - How many times a particular App has been downloaded — where is this info? 如何知道locationManager.requestAlwaysAuthorization()是否已被询问 - How to know if locationManager.requestAlwaysAuthorization() has already been asked 如何知道MPMoviePlayerController何时在iPhone中暂停? - How to know when the MPMoviePlayerController has been paused in iPhone? 我如何知道UITextField的文本是否已被用户修改 - How do I know if the text of a UITextField has been modified by user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM