문제

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