views:

39

answers:

1

I am using a grouped tableview and need to resize 1 cell where the enclosed cell.detailTextLabel has exceeded the size of the cell (i.e. about 3 lines worth).

Is there any easy way for the cell to auto-size itself to it's contents or otherwise, how do I change the size of that particular cell?

+3  A: 

The UITableViewDelegate has a method called tableView:heightForRowAtIndexPath:. Just have it return the desired height for each row.

James Huddleston
How can you work out the height based on the text in the label?
WaterBoy
Check out the `sizeWithFont:constrainedToSize:lineBreakMode:` method of NSString. Once you know how much space your text label needs, you can determine the height of the cell.
James Huddleston
Thanks James, that's really helpful
WaterBoy