這是搜索到的原文
1、在Cell對應(yīng)的xib文件中建立完整的約束。
2、使用
[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]
我的理解就是通過autolayout使用這個(gè)方法自動(dòng)計(jì)算出cell的高度
方法對cell進(jìn)行動(dòng)態(tài)計(jì)算高度,然后在
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
返回cell的高度。
注意:
[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]
一定是cell.contentView,不能用cell。