Sto sviluppando un'applicazione iOS e sto utilizzando SDWebImage come API di downloader di immagini.SDWebImage non mostra un'immagine sebbene l'immagine esista da remoto sul server
sto usando un UICollectionView e lo faccio nel metodo
- (UICollectionViewCell *)collectionView:(SMToplinksCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
Alcune immagini vengono scaricate, e alcuni non lo sono. Quelli che non hanno scaricato mostra il messaggio di errore:
2014-06-15 12:11:50.203 c_shadow_ios_iphone[6867:60b] ===Error:Error Domain=NSURLErrorDomain Code=-1100 "The operation couldn’t be completed. (NSURLErrorDomain error -1100.)"
Errore -1100: NSURLErrorFileDoesNotExist
Inoltre, l'UIImage sembra essere pari a zero.
Ho controllato l'URL che SDWebImage tenta di scaricare e mi viene l'immagine correttamente, quindi l'errore non sembra ragionevole
ecco il codice metodo che uso:
- (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;
}
uscita
image is NIL
Error: Error Domain=NSURLErrorDomain Code=-1100 "The operation couldn’t be completed. (NSURLErrorDomain error -1100.)"
Cosa mi manca qui?
Hai usato UIImageView + AFNetworking per le immagini? – Nirav
Ho usato UIImageView + WebCache.h come suggerito in SDWebImage ReadMe – raven99
Risolvi? Ho il problema simile. ty – George