Вопрос

Currently I am integrating SDWebImage in my project,

1)#import "UIButton+WebCache.h"

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:

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

/**
* Check if image has already been cached
*/
- (BOOL)diskImageExistsForURL:(NSURL *)url;

Search for memcache setObject in the project, this line stores the image in cache once downloaded.. After this line, you can post a notification and check it in your own class.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top