Is it possible to have differing heights in a UITableView Cell when I use several different ways of displaying the cell?

后端 未结 11 1299
一整个雨季
一整个雨季 2020-12-21 19:25

I\'ve spent several days trying to figure this out, but there doesn\'t seem to be a solution. I have a very basic UITableView cell with two labels in it. One of them will be

11条回答
  •  春和景丽
    2020-12-21 20:13

    As of iOS 9.1 UIStackView doesn't implement intrinsicContentSize: so the table view can't calculate the height of each cell, thus they are displayed at the estimated height instead.

    So, ideally you would simplify your code to mean you don't use a stack view and you don't keep adding and removing (and creating and destroying) views all the time. The root of the solution is to not use a stack view though.

    You can continue to use a stack view if you want, but you'll need to create a subclass and implement intrinsicContentSize:. Your reason for using the stack view shouldn't be required though as you can configure the constraints to match first baselines.

提交回复
热议问题