Open czb1n opened 7 years ago
you can try set priority when you meet the bottom view, like this, [_commentLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_contentLb.mas_bottom).mas_equalTo(10).priority(991); make.right.mas_equalTo(-10); make.bottom.mas_equalTo(-12); }];
<NSLayoutConstraint:0x600000695d60 UITableViewCellContentView:0x7f8bcc716480.height == 44> 这个是因为你没有设置tableView.estimateHeight,随便设置一个正数应该可以解决。
虽然这个这个conflict没了,但你会发现10.3上有时候计算高度还可能不准,目前我用UITableViewAutomaticDimension来做兼容。
@changyiyao 设置了estimateHeight还是不行..冲突还在..
设置top 和 bottom 约束优先级可以解决
[self.lbContent mas_makeConstraints:^(MASConstraintMaker make) { make.top.equalTo(self.contentView.mas_top).offset(53).priorityHigh();; make.left.equalTo(self.lbName); make.right.equalTo(self.contentView.mas_right).offset(-20); }]; [self.bottomLine mas_makeConstraints:^(MASConstraintMaker make) { make.left.equalTo(self.contentView).offset(60); make.right.equalTo(self.contentView).offset(-10); make.height.equalTo(@0.5); make.top.equalTo(self.lbContent.mas_bottom).offset(10); make.bottom.equalTo(self.contentView.mas_bottom).priorityHigh(); }];
ContentView 一直计算到为Cell的默认高度导致约束冲突. ( "<MASLayoutConstraint:0x600000ea3c60 UILabel:0x7f8bcc712910.height == 21>", "<MASLayoutConstraint:0x600000ea3d80 UILabel:0x7f8bcc712910.top == UITableViewCellContentView:0x7f8bcc716480.top + 10>", "<MASLayoutConstraint:0x600000ea3e40 UILabel:0x7f8bcc712910.bottom == UITableViewCellContentView:0x7f8bcc716480.bottom - 10>", "<NSLayoutConstraint:0x600000695d60 UITableViewCellContentView:0x7f8bcc716480.height == 44>" )