Dynamic Cell Heights
Currently, the cells have a fixed height of 65 points. It is much better to allow the content of the cell to drive its height. That way, if the content ever changes, the table view cell’s height can change automatically.
You can achieve this goal, as you have probably guessed, with Auto Layout. The UITableViewCell needs to have vertical constraints that will exactly determine the height of the cell. Currently, ItemCell does not have sufficient constraints for this. You need to add a constraint between the two left labels that fixes the vertical spacing between them.
First, open Main.storyboard. Control-drag from the nameLabel to the serialNumberLabel and select Vertical Spacing.
Next, open ItemsViewController.swift ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access