注册

UITableviewCell 使用Masonry撑开cell高度 遇见[LayoutConstraints] Unable to simultaneously satisfy constraints

1、问题描述

在布局UITableviewCell 内容时, 可用使用Masonry方便的自动计算高度撑开布局,但是当遇到cell高度不同,多个复杂的子view竖向排列时,容易产生高度计算冲突问题导致报如下一坨

0166ddaf7de4201cd39ca4863f47d096.png

2、解决办法

使用 Masonry 的 priorityHigh 属性来确定优先级

/**
* Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh
*/
- (MASConstraint * (^)(void))priorityHigh;

具体使用要设置 <最后一个子view> 的 bottom 属性 priorityHigh()

[self.lastView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.topView.mas_bottom).offset(5);
make.left.equalTo(superView).offset(36);
make.right.equalTo(superView).offset(-16);
make.bottom.equalTo(self.contentView).offset(-16).priorityHigh();
}];

转自:https://www.jianshu.com/p/b334b69ab82e

0 个评论

要回复文章请先登录注册