0

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;
}
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162
  • possible duplicate of [On iOS, how to make a cell.imageView refresh its content?](http://stackoverflow.com/questions/12209380/on-ios-how-to-make-a-cell-imageview-refresh-its-content) – Carl Veazey May 14 '13 at 09:04
  • 1
    may be that's because your cell is being dequed, can you give your whole `cellForRowAtIndexPath:` code , or atleast the initializing of cell part – Bonnie May 14 '13 at 09:04
  • @Bonnie I editet my post – iOS.Lover May 14 '13 at 09:13

2 Answers2

1

Try this

[ cell.imageView.image  setImageWithURL:[NSURL URLWithString:[dictionary objectForKey:@"image"]]placeholderImage:[UIImage imageNamed:NEWSAVATAR]];
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
0

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.

Ayush Goel
  • 1,103
  • 1
  • 7
  • 7