Fun is one of the most important and underrated ingredients in any successful venture. If you're not having fun, then it's probably time to call it quits and try something else.
- Richard Branson
In iOS 8, Apple introduces a new feature for
UITableView known as Self Sizing Cells. This is seriously one of the most useful features of the SDK. Prior to iOS 8, if you want to display dynamic content in a table view with multiple rows, you have to calculate the row height of a cell manually. Now iOS is capable to determine the row height for you. All you need to do is write a couple lines of code and make sure you define all the layout constraints for the prototype cell (that we have already done).
Self sizing cells are particularly useful to support Dynamic Type. By using Dynamic Type, your app can respond to the text change and allow users to customise the text size to fit their own needs. Dynamic Type is another topic which will be covered in this chapter.
Let's start with self sizing cells. In summary, here are the procedures to implement self sizing cells:
estimatedRowHeightproperty of your table view
rowHeightproperty of your table view to
Want to learn more about Swift 3 and build a real world app? Get a full copy of the book here.