Ios mas_updateConstraints没有';t消除砌体中的约束

Ios mas_updateConstraints没有';t消除砌体中的约束,ios,uitableview,autolayout,nslayoutconstraint,masonry-ios-osx,Ios,Uitableview,Autolayout,Nslayoutconstraint,Masonry Ios Osx,我在我的UITableViewCell中使用,该单元格有两个子视图,一个是contentLabel,另一个是imageView。 虽然imageView并不总是存在,但如果单元格有一个图像url,请将其显示或隐藏。如果imageView被隐藏,我想将contentLabel设置为cell.contentView.bottom另一个值,如下所示: [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.

我在我的
UITableViewCell
中使用,该单元格有两个子视图,一个是
contentLabel
,另一个是
imageView
。 虽然
imageView
并不总是存在,但如果单元格有一个图像url,请将其显示或隐藏。如果
imageView
被隐藏,我想将
contentLabel
设置为
cell.contentView.bottom
另一个值,如下所示:

  [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.contentView.mas_left);
    make.top.equalTo(self.contentView.mas_bottom).offset(20);
    make.right.equalTo(self.contentView.mas_right).offset(-6);
    _bottomConstraint = make.bottom.equalTo(_imageView.mas_top).offset(-14);
  }];

  [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(_contentLabel.mas_left);
    make.bottom.equalTo(self.contentView.mas_bottom).offset(-14);
  }];

  if (tweet.imageUrl) {
    _imageView.hidden = NO;
    [_imageView sd_setImageWithURL:tweet.imageUrl placeholderImage:[UIImage imageNamed:@"loading"] options:0];
  } else {
    _imageView.hidden = YES;
    [_imageView sd_setImageWithURL:NULL];
  }

  if (_imageView.hidden) {
    [_contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
      make.bottom.equalTo(_imageView.mas_top).offset(0);
    }];
  }
但我总是收到下面的错误消息:

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<MASLayoutConstraint:0x7fef9cd178d0 UILabel:0x7fef9cd437e0.bottom == UIImageView:0x7fef9cd26260.top - 14>",
    "<MASLayoutConstraint:0x7fef9caf5430 UILabel:0x7fef9cd437e0.bottom == UIImageView:0x7fef9cd26260.top>"
)

Will attempt to recover by breaking constraint 
<MASLayoutConstraint:0x7fef9caf5430 UILabel:0x7fef9cd437e0.bottom == UIImageView:0x7fef9cd26260.top>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。

这似乎
mas\u updateConstraints
没有删除旧约束,而是添加了一个新约束,两者相互冲突。那么,如何在运行时动态更新约束值呢?

也许这不是您的问题,但它可能会帮助其他人:

我的问题主要是:

我首先将高度约束指定给
UIView
的子类:

make.height.equalTo(label); // label is another subclass of UIView
后来,我尝试使用以下方法“更新”该约束:

make.height.equalTo(@(newHeight)); // newHeight is a CGFloat  
这使原始约束保持安装状态,并添加了与第一个约束冲突的新约束

然后,我将第一个约束的赋值更改为:

CGFloat labelHeight = label.frame.size.height;
make.height.equalTo(@(labelHeight)); 
…冲突消失了。

显然,iOS无法将
UIView
定义的约束更新为
NSNumber
定义的约束