Bawpotter Bawpotter - 7 months ago 91
Objective-C Question

Self-Sizing UITableViewCell iOS 8

I am currently trying to implement the self-sizing table view cells into my iOS 8 app. Previously, I used a static table view to display my content, but in order to use the self-sizing feature, I had to switch it to dynamic/prototype. I have 8 different prototype cells, each with different identifiers. I am looking to self-size SOME of my prototype cells, but not others. Is this doable?


In cellForRowAtIndexPath, if the cell should be self-sizing:

tableView.estimatedRowHeight = (your default row height)
tableView.rowHeight = UITableViewAutomaticDimension

In heightForRowAtIndexPath, if the cell should be self-sizing:

return UITableViewAutomaticDimension

Otherwise, if you want a static, non-resizing cell, in heightForRowAtIndexPath,

return (your default row height)