Set TableView height by the number or rows

前端 未结 9 1592
不思量自难忘°
不思量自难忘° 2021-01-31 10:40

I have got TableView in the MainstoryBoard and the number of rows is random every time. I want the height of the whole TableView to be fl

9条回答
  •  温柔的废话
    2021-01-31 11:28

    Take outlet of the Height Constraint of the parent view and assign it the height of table view's content + constant(extra height of other contents in the view)

    heightConstraintView.constant = tableView.contentSize.height + constantValue //use the value of constant as required.
    

    and write this code in the cellForRowAt method.

提交回复
热议问题