Resize the Table cell height as per downloaded image height

前端 未结 6 905
一生所求
一生所求 2021-01-05 07:04

I am getting the image\'s URL at run time and I want to download & display these images in a table. Images are going to be download asynchronously. What is more importan

6条回答
  •  醉酒成梦
    2021-01-05 07:44

    On the delegate method you have to update the image when finished downloading you can use

    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] 
                     withRowAnimation:UITableViewRowAnimationAutomatic];
    

    This will call again

        -(CGFloat)tableView:(UITableView *)tableView
    heightForRowAtIndexPath:(NSIndexPath *)indexPath
    

    So you should have it using the image's height if it exists, a default heigh, or a placeholder image if you have one.

提交回复
热议问题