1、cell的要求
cell中的控件設(shè)置約束的原則是必須要保證cell的控件的約束必須與cell 的contentView的上下產(chǎn)生聯(lián)系,舉個(gè)簡單的例子,如果cell上就有一個(gè)label,那么label的約束 如下
[self.contentView addSubview:self.stateLabel];
[self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.left.equalTo(self.contentView.mas_left);
? ? ? ? make.right.equalTo(@-10);?
? ? ? ? make.top.equalTo(self.contentView.mas_top).offset(5);
? ? ? ? make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
? ? }];
注意,重點(diǎn)是設(shè)置bottom的約束
2、tableview的要求
self.tableView.rowHeight = UITableViewAutomaticDimension;?
self.tableView.estimatedRowHeight = 100;?
不需要實(shí)現(xiàn)HeightForRow的代理方法
然后 就是你想要的了。