Inside ScrollView there are two Label (multi-lane), and below it is a TableView (in which the number of rows may also be different).

The height of both Label and TableView is not specified. The row height at the TableView is fixed and equal to 50.0f.

All outlets have constants set apart from each other - in particular from above and below, including the View container in which they are all located.

As a result: both Labels are scrolled, and the TableView is obtained with a height of 0. It can only be seen if the table height is set explicitly. The number of rows of the TableView is determined correctly.

How can you programmatically set the height of the TableView itself so that it can be seen ("row height" x "number of cells")?

Or you can do something else?

enter image description hereenter image description here

  • Do you have cells of different sizes or all of the same height? - runia
  • The height of the cells in this case is not dynamic - the same. - Chekist

1 answer 1

Apt on the English stackoverflow.

  1. You must set the constraint for the height of the table. I selected "Height> = 0" so that the table is not visible if it is not filled.

  2. In .h add @property (strong, nonatomic) IBOutlet NSLayoutConstraint *myTableHeight; and link the line to the constraint you just added via the storyboard.

  3. In viewDidLayoutSubviews : self.myTableHeight.constant = self.myTableView.contentSize.height;