Reputation: 41490
In setting up your UITableView use to self-sizing cell, you have to specify estimatedRowHeight. Why is this even needed - given that the cell height will be calculated first by the system before the cell is displayed?
Upvotes: 3
Views: 2255
Reputation: 2905
Setting the row height to UITableViewAutomaticDimension (-1), tells the auto layout engine that it needs to solve for the row height. The estimated height gives the engine a starting guess for solving the layout constraint equations.
From the documentation for the estimatedRowHeight:
Providing a nonnegative estimate of the height of rows can improve the performance of loading the table view. If the table contains variable height rows, it might be expensive to calculate all their heights when the table loads. Using estimation allows you to defer some of the cost of geometry calculation from load time to scrolling time.
When you create a self-sizing table view cell, you need to set this property and use constraints to define the cell’s size.
Upvotes: 6