I want to set a thumbnail image url and high res image url so that first thumbnail image is downloaded and then the high res image is downloaded
Actually, you don't need to create any hidden UIImageView
to do the trick.
What you must do is set the first URL (with the smaller image) to be directly downloaded into your UIImageView
, and then use SDWebImageManager
to download the larger version on the background. When it finishes download, simply set the downloaded image in your image view.
Here's how you can do that:
// First let the smaller image download naturally
[self.imageView setImageWithURL:self.imageURL];
// Slowly download the larger version of the image
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadWithURL:self.currentPhoto.largeImageURL options:SDWebImageLowPriority progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
if (image) {
[self.imageView setImage:image];
}
}];
Note how I used SDWebImageLowPriority
option. This way, the image (which should be naturally larger than the first one) will be downloaded in a low priority and should not cancel the first download.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With