Search code examples
iphoneiosuitableviewautosize

how to get a UITableView row height to auto-size to the size of the UITableViewCell?


How to get a UITableView row height to auto-size to the size of the UITableViewCell?

So assuming I'm creating the UITableViewCell in Interface Builder, and it height is more than the standard size, how can I get the UITableView row height to autosize to it? (i.e. as opposed to manually having to measure the height in interface builder and than programmatically setting it)


Solution

  • If all the cells are the same, set the rowHeight property on UITableView to the size of your cell. If they're all different based on content, you're going to have to implement -tableView:heightForRowAtIndexPath: and calculate the height for each row based on your data source.