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.

4

0 回答 0