0

I need images from URLs in my app and I also need to cache them for reuse.

Here is my code to download various images from various URLs:

 __block UIActivityIndicatorView *activityIndicator = [UIActivityIndicatorView.alloc   initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

[imgView addSubview:activityIndicator];
activityIndicator.center = CGPointMake(65, 65);

[activityIndicator startAnimating];

[imgView setImageWithURL:imageURL placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
{
    if (error)
        NSLog(@"%@", [error description]);

    [activityIndicator removeFromSuperview];
    activityIndicator = nil;
}];

At a time I fire 4 requests. Out of them, only 3 gets the actual image. Remaining 1 image does not download and activityIndicator keeps animating forever.

Is there something I am missing in above code? I have copied this from their own example that comes with the SDK.

Nirav Bhatt
  • 6,940
  • 5
  • 45
  • 89
  • 1. Does it logs any error on console? 2. Does it fail always on the same image or it happens on random image? In the former case - are you sure the URL is valid? – Valerii Hiora Jun 02 '13 at 14:03
  • No logs. And it fails on the same URL. Yes, the URL is valid. It works fine if I don't use SDWebImage. – Nirav Bhatt Jun 02 '13 at 16:16
  • Try to remove the app completely from Simulator or device and reinstall it. – Valerii Hiora Jun 02 '13 at 16:34
  • Explanation: may be SDWebImage corrupted its cache in one of the app runs and now extracts the broken image and therefore it fails to load into image view – Valerii Hiora Jun 02 '13 at 16:35
  • I attempted to reset iOS simulator and cleaned all builds etc. But still don't see this image. One more issue I see today is: For those images that I successfully get from URL, when I access them again they are automatically scaled down! Seems like I will end up writing my own caching routine! – Nirav Bhatt Jun 03 '13 at 18:42

0 Answers0