使用Masonry让cell高度自适

首先注销tableview自身设置高度的方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

 

然后

_tableView.estimatedRowHeight = 100;//这个高度随意 设置!但是必须 要设置

 _tableView.rowHeight = UITableViewAutomaticDimension;//告诉tableView的真实高度是自动计算的,根据你的约束来计算

 

//注册你的cell 如果没有自定义cell 这里使用 UITableViewCell就可以 

  [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"xxxxxx"];

 

重点来了 如果完全使用系统自身的UI可忽略下面步骤

  make.bottom.equalTo(self.mas_bottom).offset(0);

 一定要设置你的最后一个控件 的底部为cell的底部!

 

posted @ 2017-09-14 10:44  烟沿檐烟燕眼  阅读(457)  评论(0)    收藏  举报