Dynamic Height Issue for UITableView Cells (Swift)

前端 未结 25 2532
温柔的废话
温柔的废话 2020-11-28 04:39

Dynamic text of variable length are being injected into tableview cell labels. In order for the tableview cells\' heights to be dynamically sized, I have implemented in

相关标签:
25条回答
  • 2020-11-28 05:12

    This is simple when doing 2 things:

    1. setting the automatic height
    tableView.rowHeight = UITableView.automaticDimension
    
    1. creating all TableViewCells with FULL constraints from top to bottom. The last element MUST define some bottom spacing to end the cell.

    So the layout engine can compute the cell heigth and apply the value correctly.

    0 讨论(0)
提交回复
热议问题