Previously, I talked about a method using GDC. Today, I’m going to talk about another simple method using the AFNetworking. You can download the AFNetworking from this link
If you are using a your own custom cell, import "UIImageView+AFNetworking.h" herder file to your custom cell. Or if you are not using a custom cell, import that herder file to your table view.
Here, we call setImageWithURL method, which returns an image view. This method accepts NSURL, so we need to convert our string URL to NSURL. Also I have added a placeholder image. So this placeholder image will load until the real image loads.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
............ | |
............ | |
[cell.imageView setImageWithURL:[self GetImageURLForMember:member.MemberId] placeholderImage:[UIImage imageNamed:@"profil | |
e-image-placeholder"]]; | |
............... | |
............... | |
} | |
-(NSURL *)GetImageURLForMember : (NSString *) memberId | |
{ | |
NSString *imageUrl = [self GetStringURLForMember:memberId]; | |
NSURL *url = [[NSURL alloc]initWithString:imageUrl]; | |
return url; | |
} |
No comments:
Post a Comment