Unable to simultaneously satisfy constraints

[aSubView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10);
        make.right.equalTo(self).offset(-10);

代码如上。原因是在设定了子view的left和right后,
就隐藏了一个条件:superView的width必须大于等于20,

才能满足上面的条件。

但如果上面的代码是放在superView的init中的话,
此时superView的约束还没有加上,因为view必须
addSubview之后,才能增加约束。
此时系统给superView默认加了个width = 0的约束,
就和superView的width必须必须大于等于20的条件
冲突了。


解决办法:
[aSubView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10);
        make.right.equalTo(self).offset(-10).priority(900);;





警告如下:
[LayoutConstraints] 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. 
(
<MASLayoutConstraint:0x6040002a0000 UILabel:0x7f9a1ee29800.left == PfasDetailInfoView:0x7f9a1ee28bb0.left + 11>,
<MASLayoutConstraint:0x6040002a0180 UILabel:0x7f9a1ee29800.right == PfasDetailInfoView:0x7f9a1ee28bb0.right - 15>,
<NSLayoutConstraint:0x604000286fe0 PfasDetailInfoView:0x7f9a1ee28bb0.width == 0>,
)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值