SnapKit / Masonry

Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout
MIT License
18.05k stars 3.14k forks source link

xcode shows alert when my table view footer view's subview use masonry to do auotolayout #425

Open beautylim opened 7 years ago

beautylim commented 7 years ago

New Issue Checklist

🚫 If this template is not filled out your issue will be closed with no comment. 🚫

Issue Info

Info Value
Platform ios
Platform Version 9.0
Masonry Version 1.0.1
Integration Method cocoapods

Issue Description

⚠️I init a footer view and have set its frame. The footer view's subview (such as UILabel,UIButton) use masonry to do constrain their left and right margin , but Xcode say i shouldn't set subview's right margin, why? And after i set it's width, everything become ok, but it 's not elegant

footer view init code

_addCashierFooterView = [[MposAddCashierFooterView alloc] initWithFrame:CGRectMake(0, 0, WIDTH_SCREEN, 300.f)];

footer view subview use masonry


[self.noteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).with.offset(5.f);
        make.left.equalTo(self).with.offset(25.f);
        make.right.equalTo(self).with.offset(-25.f);
    }];

    [self.submmitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.noteLabel.mas_bottom).with.offset(20.f);
        make.left.equalTo(self).offset(50.f);
        make.right.equalTo(self).offset(-50.f);
        make.height.mas_equalTo(50.f);
    }];

Xcode alert message

2017-03-22 18:02:54.427511 UMSMposI[57173:313304] [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:0x6000002af2a0 UIButton:0x7f9c63581d70.left == MposAddCashierFooterView:0x7f9c63581500.left + 50>",
    "<MASLayoutConstraint:0x6000002b0140 UIButton:0x7f9c63581d70.right == MposAddCashierFooterView:0x7f9c63581500.right - 50>",
    "<NSLayoutConstraint:0x60800009d6f0 MposAddCashierFooterView:0x7f9c63581500.width == 0>"
)

Will attempt to recover by breaking constraint 
<MASLayoutConstraint:0x6000002b0140 UIButton:0x7f9c63581d70.right == MposAddCashierFooterView:0x7f9c63581500.right - 50>

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.
2017-03-22 18:02:54.430166 UMSMposI[57173:313304] [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:0x6080002aaaa0 UILabel:0x7f9c63581ae0.left == MposAddCashierFooterView:0x7f9c63581500.left + 25>",
    "<MASLayoutConstraint:0x6080002aaec0 UILabel:0x7f9c63581ae0.right == MposAddCashierFooterView:0x7f9c63581500.right - 25>",
    "<NSLayoutConstraint:0x60800009d6f0 MposAddCashierFooterView:0x7f9c63581500.width == 0>"
)

Will attempt to recover by breaking constraint 
<MASLayoutConstraint:0x6080002aaec0 UILabel:0x7f9c63581ae0.right == MposAddCashierFooterView:0x7f9c63581500.right - 25>

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.

⚠️