SDWebImage does not display the image, although the image exists remotely on the server

I am developing an iOS application and I am using SDWebImage as the image downloader API.

I am using a UICollectionView and I am doing this in a method

- (UICollectionViewCell *)collectionView:(SMToplinksCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

Some images are uploaded, and some are not. In messages that do not load, an error message is displayed:

2014-06-15 12: 11: 50.203 c_shadow_ios_iphone [6867: 60b] === Error: Domain error = NSURLErrorDomain Code = -1100 "Operation could not be completed. (NSURLErrorDomain error -1100.)"

Error -1100: NSURLErrorFileDoesNotExist

In addition, UIImage seems to be null.

I checked the URL that SDWebImage is trying to load and it displays the image correctly, so the error does not seem reasonable.

Here is the code of the method I'm using:

 - (UICollectionViewCell *)collectionView:(SMToplinksCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { SMToplinkCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:TopLinksCollectionViewID forIndexPath:indexPath]; NSArray *collectionViewArray = [self getToplinksArrayAccordingToTheIndex:collectionView.index]; // CONFIGURE THE CELL SMTopLinksObject *dataObject = collectionViewArray[indexPath.item]; // 1. Set the toplink title cell.title = dataObject.name; // 2. Get the default image and blur it cell.imageName = dataObject.localImageName; // 3. Activate the preloader that shows the loading status // 4. Load the image from the server SDWebImageManager *manager = [SDWebImageManager sharedManager]; NSString *toplinksGetRequest = dataObject.prepareToplinksGetRequest; NSURL *toplinksURL = [NSURL URLWithString:toplinksGetRequest]; NSLog(@"=== Trying to download image from URL:%@", toplinksGetRequest); [manager downloadWithURL:toplinksURL options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize){ //progression tracking code } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished){ if(finished) { NSLog(@"===image finished loading, image:%@", image); NSLog(@"===Error:%@", error); } if (image) { cell.shadowPageImageView.image = image; } }]; NSLog(@"=========Cell:%@", cell); return cell; } 

Exit

Image - NIL

Error: Error Domain = NSURLErrorDomain Code = -1100 "Operation could not be completed (error NSURLErrorDomain -1100.)"

What am I missing here?

+6
ios objective-c image uicollectionview sdwebimage
source share
7 answers
 [cell.diviceIV sd_setImageWithURL:[NSURL URLWithString:imgStringUrl] placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { if (image){ // Set your image over here }else{ //something went wrong } }]; 

The main thing is the options: SDWebImageRetryFailed, which you need to specify in your method. It works for me, you can try.

+4
source share

I had the same problem. I got "Error Domain = SDWebImageErrorDomain Code = -1" while trying to load a null url, but the image is present in that particular url. I found that an error occurs for low resolution images. For better quality images, downloading is going well. Check the same code for higher resolution images.

+3
source share

Download the latest version of SDWebImage from https://github.com/rs/SDWebImage and try again.

He will work.

0
source share

Try the following code

Import the category imageView #import <SDWebImage/UIImageView+WebCache.h> which is already in SDWebImage

Then in your cell for cellForItemAtIndexPath

 [cell.imgVwUser sd_setImageWithURL:[NSURL URLWithString:objPhoto.imageUrl] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { DLogs(@"completed"); [cell.loadIndicator stopAnimating]; }]; 
0
source share

I ran into the same problem. I tried all the paths mentioned above, but could not work normally.

Finally, I found out that the reason is the name of the image URL. I think that iOS does not support the Chinese name of the image url. Therefore, you must recode the url.

Example:

 url = [_img_url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
0
source share

For me, the question was very low resolution images. For high resolution, this works great !!!!

0
source share

Use it as

 self.imgUserProfile.sd_setImage(with: imageUrl, placeholderImage: UIImage(named: "profile_placeholder"), options: SDWebImageOptions.refreshCached, progress: nil, completed: { (image, error, cache, url) in if error == nil { self.imgUserProfile.image = image } }) 
0
source share

All Articles