Currently i am integrating SDWebImage in my project by following below things
1)#import \"UIButton+WebCache.h\"
2)[button setImageWithURL:url placeholderImag
The best way I have found to do this is to use the SDWebImageManager class. Your view controller or some other class will then need to conform to the SDWebImageManagerDelegate protocol.
SDWebImageManager *manager = [SDWebImageManager sharedManager];
UIImage *cachedImage = [manager imageWithURL:url];
if (cachedImage) {
[button setImage:cachedImage];
// stop or remove your UIActivityIndicatorView here
}
else {
[manager downloadWithURL:url delegate:self];
}
Once the image has been downloaded the delegate method will be called:
- (void)webImageManager:(SDWebImageManager *)imageManager didFinishWithImage:(UIImage *)image {
[button setImage:image];
// stop or remove your UIActivityIndicatorView here
}
There is also a delegate method for when an error occurs downloading an image
- (void)webImageManager:(SDWebImageManager *)imageManager didFailWithError:(NSError *)error {
// Handle error here
}
If you have more than one button you may have problems determining which image belongs to which button after the image has downloaded. In this case you may need to have a button subclass which handles the download as above and then updates its own image.
Hope that helps.