對(duì)于cell中的子控件使用autolayout布局的tableview,iOS 8+可以使用以下代碼高度自適應(yīng)
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 100;
estimatedRowHeight此處值可以填寫(xiě)不為0的任意值祝高,不能不設(shè)置涣达。
如果iOS 8使用了以上自適應(yīng)方法算利,但單元格并沒(méi)有自適應(yīng)册踩,需要在cellForRowAtIndexPath方法中,添加如下代碼
[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];
以上方法添加在return cell 之前