Dynamic UITableView height

后端 未结 11 1643
無奈伤痛
無奈伤痛 2020-12-29 09:47

I would like to set the UITableView to match the height for all the contents in the table view.

This is my storyboard

The problem with this is the t

11条回答
  •  抹茶落季
    2020-12-29 10:02

    Based on solution of @rr1g0

    Updated for Swift 5 in 2020, and works with TableViews with sections too.

    Create height constraint for tableView and create an outlet to it. And in viewDidLayoutSubviews() use the code below:

    var tableViewHeight: CGFloat = 0
    
    for section in 0..

提交回复
热议问题