Reputation: 6051
I am using AFNetworking to download images from server , everything works fine but images wont't be appear unless I scroll table view . here is my code :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
//configuring news feed
dictionary = [newsFeed objectAtIndex:indexPath.row];
//display thumbnails
UIImageView *image = [[UIImageView alloc]init];
[image setImageWithURL:[NSURL URLWithString:[dictionary objectForKey:@"image"]]placeholderImage:[UIImage imageNamed:NEWSAVATAR]];
cell.imageView.image = [image.image imageScaledToSize:CGSizeMake(55, 55)];
[cell setNeedsLayout];
return cell;
}
Upvotes: 0
Views: 1065
Reputation: 1103
This delegate method is called only when that cell is visible i.e you have scrolled to the cell. If you dont want this to happen you have to call a web-service and save all the images locally and then pick it from your local folder.
Upvotes: 0
Reputation: 20021
Try this
[ cell.imageView.image setImageWithURL:[NSURL URLWithString:[dictionary objectForKey:@"image"]]placeholderImage:[UIImage imageNamed:NEWSAVATAR]];
Upvotes: 1