0

I am trying to set image in UICollectionViewCell, via collectionView:cellForItemAtIndexPath:. I am using AFNetworking Image Category UIImageView+AFNetworking.h method for loading image from cloud server.

The problem is that, I am always hitting failure block. When open the link in browser window, I can see the image.

Here is the sample code:

    __weak UICollectionViewCell *blockcell = cell;

    NSURL *imageUrl = [NSURL URLWithString:@"https://ec2-75-101-163-253.compute-1.amazonaws.com/static/icons/app-excel%402x.png"];
    [cell.appImage setImageWithURLRequest:[NSURLRequest requestWithURL:imageUrl] placeholderImage:[UIImage imageNamed:@"file-gray.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
    blockcell.appImage.image = image;
        [blockcell setNeedsLayout];
    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
        NSLog(@"fail for %@",request.URL);
    }];

There might be a simple/silly mistake. Can anyone help me. Thanks in advance.

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
code2kick
  • 83
  • 1
  • 6
  • 3
    The SSL certificate is not valid, just open the URL in a browser. – rckoenes Aug 29 '13 at 09:11
  • Solved it: We need to ignore SSL - just set this flag for operation requestOperation.allowsInvalidSSLCertificate = YES; – code2kick Aug 29 '13 at 09:53
  • Duplicate of this http://stackoverflow.com/questions/12967220/i-want-to-allow-invalid-ssl-certificates-with-afnetworking – code2kick Aug 29 '13 at 09:54
  • @code2kick actually the solution you should go for is to use a proper SSL certificate. – Gabriele Petronella Aug 29 '13 at 09:57
  • @GabrielePetronella Yes, I have confirmed with my server team, server is in development stage, they will add a valid certificate in the future. Marked a //TODO message to revert in the future. – code2kick Aug 29 '13 at 10:06

0 Answers0