One simple and extremely helpful improvement introduced in iOS 8 SDK is the auto-sizing of UITableViewCells.
Prior to iOS 8, if you had a UITableView
that has cells with varying heights, you'd have to implement UITableViewDelegate
's -tableView:heightForRowAtIndexPath:
and return a height based on -systemLayoutSizeFittingSize:
, potentially caching the heights yourself.
In iOS 8, this becomes much easier if you do the following:
- Use Auto Layout for your UITableViewCell (subclass).
- Set UITableView.rowHeight = UITableViewAutomaticDimension
- Set UITableView.estimatedRowHeight or implement -tableView:estimatedHeightForRowAtIndexPath:
You don't (and shouldn't) implement -tableView:heightForRowAtIndexPath:
anymore!
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.
.