0

I am using asyncimageview in the uitableview for displaying the image in the uitableviewcell but when scrolling the tableview the image are not displayed directly. it first display old one and the present the new image from the url. its not caching or not displaying from cache.

if (Cell == nil) { 
    Cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    Cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    //Create Cell Method 
    [self CreateCell:FollowCell atIndexPath:indexPath]; } 

    // Set Cell Method 
    [self SetCell:FollowCell atIndexPath:indexPath]; 
    [Cell setClipsToBounds:YES]; 
    return FollowCell;
    // Image code  
    [asyncImgUser setImageURL:[NSURL URLWithString:strUserImage] andPlaceHolder:[UIImage imageNamed:@"Placeholder.png"]];
}
Aanabidden
  • 375
  • 6
  • 18
Gaurav Parmar
  • 447
  • 2
  • 11

1 Answers1

0

TableViewCells are reused by TableView for this reason initially old image is shown and after your image is loaded by the async task it displays new image. And if it happens always it means your caching is working.

Aanabidden
  • 375
  • 6
  • 18
  • Tableview cell are reused but as in other application placeholder is displayed till image loads and once image is loaded then it never show placeholder or older image in the tableview cell it always shows right image only. – Gaurav Parmar Jun 22 '15 at 04:48
  • yes because a placeholder image is set in `cellForRowAtIndexPath` method until it gets downloaded. – Aanabidden Jun 22 '15 at 09:07
  • but it is not showing placeholder its showing me older image of last cell which is set after downloading. – Gaurav Parmar Jun 22 '15 at 10:21
  • Cellforrowindexpath and the part where you place your image – Aanabidden Jun 22 '15 at 10:28
  • if (Cell == nil) { Cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; Cell.selectionStyle = UITableViewCellSelectionStyleNone; //Create Cell Method [self CreateCell:FollowCell atIndexPath:indexPath]; } – Gaurav Parmar Jun 22 '15 at 10:33
  • // Set Cell Method [self SetCell:FollowCell atIndexPath:indexPath]; [Cell setClipsToBounds:YES]; return FollowCell; – Gaurav Parmar Jun 22 '15 at 10:33
  • [asyncImgUser setImageURL:[NSURL URLWithString:strUserImage] andPlaceHolder:[UIImage imageNamed:@"Placeholder.png"]]; – Gaurav Parmar Jun 22 '15 at 10:33
  • 1 & 2 are cellforrowatindex and last is in setcell method for setting the image in cell – Gaurav Parmar Jun 22 '15 at 10:34
  • It will be better if you edit and write it in your question – Aanabidden Jun 22 '15 at 10:44