Bawpotter Bawpotter - 1 year ago 152
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?

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download