問題
學(xué)習(xí)swift過程中遇到了個問題就是UITableView的高度自適應(yīng)UITableViewAutomaticDimension
不起作用,并且還報了個 [Warning]
[Warning] Warning once only: Detected a case where constraints
ambiguously suggest a height of zero for a tableview cell's content view.
We're considering the collapse unintentional and using standard height instead.
通用代碼設(shè)置為:
self.tableView.estimatedRowHeight = 120
self.tableView.rowHeight = UITableViewAutomaticDimension
但運行效果卻為:
before.png
解決方法
google 一番之后坯认,發(fā)現(xiàn)原來是我的cell里的控件沒有做bottom約束(AutoLayout)汗洒,所以加上Bottom約束之后的效果為:
after.png
完美