I am overloading the delegate method -tableView:heightForRowAtIndexPath:
and using -sizeWithFont:constrainedToSize:
to programmatically set the height
It's less than optimal, but the simplest solution is to call -reloadData
on the table.
A better solution would be to call -beginUpdates
, -deleteRowsAtIndexPaths:withRowAnimation:
, -insertRowsAtIndexPaths:withRowAnimation:
, and -endUpdates
or simply -reloadSections:withRowAnimation:
if targeting 3.0 only. This will add animation.
Edit: And you will also need a proper tableView:heightForRowAtIndexPath:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGSize textSize = [[self textForRowAtIndexPath:indexPath] sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake([tableView frame].size.width - 20, 500)];
return textSize.height + 13.0f;
}
(where textForRowAtIndexPath:
is a method that returns the cell's text)