ScrollView -> View (Label + Label + TableView) and autolayout

199 views Asked by At

Inside the ScrollView are two Labels (multilateral), and below it the TableView (in which the number of rows may be different).

The height of both Label and TableView is not set.

All outlets set constraints on the indents from each other above and below, including a View of the container.

In summary: both Labels height correct, but TableView is obtained with a height of 0 (not visible). It is only visible if the height is explicitly set. The number of rows of the TableView is determined correctly.

How can I programmatically set the height of the TableView to show it? ("row height" x "number of cells")? I know the height of row in TableView.

enter image description here

1

There are 1 answers

0
namanhams On BEST ANSWER

You are referring to the contentSize's height of the table view. First you need to add a height constraint for the table view. Then after the table finishes loading, do this :

self.tableViewHeightConstraint.constant = self.tableView.contentSize.height;