Scenario
I am using the automaticDimension option on UITableView. I'd like to have a single UILabel in my cell that is self-sizing to fit the text.
Setup
Here you can see how I setup the label. The edges are equal to the contentView margins.
Problem
The height is set to 37.0 points on the phone when the text fits one line. 44.0 should be the minimum.
Question
How do I have to setup the layout to maintain a minimum cell height of 44.0 (default height, fitting the other cells)?
Edit:
Using the built-in 'basic' TableViewCell with numberOfLines = 0 seems to be the most easy and best solution! Suggested by eddwinpaz. Thank you all.
Change the top anchor from
constraint(equalTo:)
togreaterThanOrEqualTo:
and the bottom one tolessThanOrEqualTo:
. Then make the label centered on theY
-Axis.Then you should set
cell. heightAnchor.constraint(greaterThanOrEqualToConstant: 44)