Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell Image not updating

I can update the detailTextLabel.text and the UITableViewCell shows the changes at runtime, but if I try to update the imageView.image it does not change the visible image. Any idea as to why? I have tried calling a refresh on the UITableViewCell specifically but to no avail.

-(void)getImageForURL:(NSURL*)url row:(UITableViewCell*)cell {

    UIImage*image;

    image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url];

    cell.imageView.image = image; // Does not work..
    cell.detailTextLabel.text = @"test"; // Works

}
like image 611
John Sloan Avatar asked Dec 10 '10 16:12

John Sloan


2 Answers

Try calling [cell setNeedsLayout] after setting the image, if it's the first image you're setting for the cell.

like image 144
arya Avatar answered Oct 18 '22 10:10

arya


Make sure the cell style is UITableViewCellStyleDefault, because other cell types may always return nil imageView, instead of creating one on demand.

like image 45
Costique Avatar answered Oct 18 '22 10:10

Costique