I am working on a twitter-like client, and there is a message list view implemented by UITableView. For each cell, it may need to load a dynamic size image, and the image is loaded async. So it size of the image is unknown when the table view loaded.
Is it possible to update the uitableviewcell's height after the image is loaded.
From my knowledge, the only way to update the height is in this method: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath But it is just called when loading data at first time. This is reasonable from performance consideration. Anyhow, is there a way to change the height later?
Thanks for any information!
Finally, I used "reloadRowsAtIndexPaths" to update particular rows, you can try this for hidden cells.
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:toReloadRows withRowAnimation: UITableViewRowAnimationNone];
[self.tableView endUpdates];
But, the cell shakes when updating the visible cells's height. So the it's better to have the cell height calculated before.
Try calling an empty Update block:
[self.tableView beginUpdates];
[self.tableView endUpdates];
This seems to work for visible cells. I'm still struggling with hidden cells.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With