Wednesday 4 December 2013

Setting UITableViewCell imageview via AFNetworking

#import "UIImageView+AFNetworking.h" Download
NSURLRequest *imageRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"YOUR_URL"]];
[cell.imageView setImageWithURLRequest:imageRequest placeholderImage:nil
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image){
        NSLog(@"success");
        cell.imageView.image = image;
        cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
        cell.imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [cell setNeedsLayout];// To update the cell {if not using this, your image is not showing over cell.}
}failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
        NSLog(@"Failure");}

No comments:

Post a Comment