Self-Sizing Table View Cells

Learn how to create self-sizing table view cells, allow them to resize on demand, support Dynamic Type, and even create them with SwiftUI. By Josh Steele.

Leave a rating/review
Save for later

Who is this for?

Intermediate iOS developers who want to do more with their UITableViews. It expects you to have familiarity with creating user interfaces with Storyboards in Interface Builder, the concept of Dynamic Type, and some basics of SwiftUI.

Covered concepts

  • Self-sizing UITableView cells
  • Dynamic Type
  • SwiftUI

Part 1: Set Up the UITableView

Toggle description

Set up the custom Auteur table view cell to grow as its content changes by applying constraints and setting properties on the UILabel.

Toggle description

Update the UITableView to be aware that its cells may be of varying sizes by declaring an estimatedRowHeight value.

Toggle description

Add in more content to the AuteurTableViewCell, adding constraints to ensure it will continue to grow as needed.

Part 2: Make Elements Dynamic

Toggle description

Layout the UI elements for the detail view, configuring the UITextView to grow when its content is changed.

Toggle description

Demonstrate how easy it is to grow a cell once AutoLayout constraint are in place by simply changing the text in a UITextView.

Toggle description

Add Dynamic Type support to the cells - which is just another type of content change to which the cell can adjust.

Part 3: Explore SwiftUI Differences

Toggle description

Implement the Auteur table in SwiftUI, taking advantage of its built-in formatting rules to make laying out the cells easier.

Toggle description

Implement the detail view in SwiftUI, add Dynamic Type support, and demonstrate how easy it is to grow the cells.