Despite having set constraints to all elements, including the vertical ones needed for the cell to calculate its height, auto-layout seems to be ignored: all cells are squeezed.
Here's a screenshot of the result and of the constraints in the storyboard:
In the VC that holds the tableView, here's the code in viewDidLoad:
tableView.estimatedRowHeight = 120.0
tableView.rowHeight = UITableViewAutomaticDimension
Commenting out the second line gives cells with a height of 120.0 but Autolayout is ignored as well.
To simplify the interface, I've left a single label with, as constraints:
And with this simplified interface, auto-layout is still not taken into account, which hints me that the problem did not come from badly set constraints.
In the Size Inspector, the row height is set on 120 and Custom is checked. The cell has the right custom class, the cell reuse identifier is correct.
Auto-layout was ignored because both the prototype cell AND the UIView of the cell had been given the custom cell class in IB.
Setting the UIView back to UIView class solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With