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

Negative offsets bug #433

Open emmanuelay opened 7 years ago

emmanuelay commented 7 years ago

New Issue Checklist

Issue Info

Info Value
Platform ios
Platform Version ios 10.3
Masonry Version 1.0.2
Integration Method manually

Issue Description

Whenever I add a negative constraint, ie. make.right.equalTo(self.mas_right).offset(-20) I get an unsatisfied constraint error. Everything else works like a charm, only negatives end up with this error.

[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. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<MASLayoutConstraint:0x6180000b1400 PageTitle:0x7f83b4623010.left == UIView:0x7f83b4622e70.left>",
    "<MASLayoutConstraint:0x6180000b1dc0 PageTitle:0x7f83b4623010.right == UIView:0x7f83b4622e70.right>",
    "<MASLayoutConstraint:0x6180000b0fe0 UIView:0x7f83b4622e70.left == UIView:0x7f83b461d5e0.left>",
    "<MASLayoutConstraint:0x6180000b0aa0 UIView:0x7f83b4622e70.right == UIView:0x7f83b461d5e0.right>",
    "<MASLayoutConstraint:0x6180000b0ce0 UIView:0x7f83b461d5e0.width == UIScrollView:0x7f83b502e000.width>",
    "<MASLayoutConstraint:0x6180000afd20 UIView:0x7f83b4623b60.width == UIScrollView:0x7f83b502e000.width>",
    "<MASLayoutConstraint:0x6180000b1f40 UIView:0x7f83b4624180.width == UIScrollView:0x7f83b502e000.width>",
    "<MASLayoutConstraint:0x6180000b1880 UIView:0x7f83b46244c0.width == UIScrollView:0x7f83b502e000.width>",
    "<MASLayoutConstraint:0x6000000afc00 UILabel:0x7f83b4623510.left == PageTitle:0x7f83b4623010.left + 20>",
    "<MASLayoutConstraint:0x6000000afcc0 UILabel:0x7f83b4623510.right == PageTitle:0x7f83b4623010.right - 20>",
    "<NSAutoresizingMaskLayoutConstraint:0x600000092f20 UIStackView:0x7f83b4511500.width == 0>",
    "<NSLayoutConstraint:0x60000008cc60 UIStackView:0x7f83b4511500.leading == UIView:0x7f83b461d5e0.leading>",
    "<NSLayoutConstraint:0x6000000911c0 UIStackView:0x7f83b4511500.trailing == UIView:0x7f83b46244c0.trailing>",
    "<NSLayoutConstraint:0x60000008f500 _UIOLAGapGuide:0x6000001c5280.leading == UIView:0x7f83b461d5e0.trailing>",
    "<NSLayoutConstraint:0x60000008ca80 _UIOLAGapGuide:0x6000001c5280.trailing == UIView:0x7f83b4623b60.leading>",
    "<NSLayoutConstraint:0x6000000916c0 _UIOLAGapGuide:0x6000001c5820.leading == UIView:0x7f83b4623b60.trailing>",
    "<NSLayoutConstraint:0x6000000915d0 _UIOLAGapGuide:0x6000001c5820.trailing == UIView:0x7f83b4624180.leading>",
    "<NSLayoutConstraint:0x60000008e9c0 _UIOLAGapGuide:0x6000001c5af0.leading == UIView:0x7f83b4624180.trailing>",
    "<NSLayoutConstraint:0x6000000909f0 _UIOLAGapGuide:0x6000001c5af0.trailing == UIView:0x7f83b46244c0.leading>",
    "<NSLayoutConstraint:0x60000008e100 _UIOLAGapGuide:0x6000001c5820.width == _UIOLAGapGuide:0x6000001c5280.width>",
    "<NSLayoutConstraint:0x6000000930b0 _UIOLAGapGuide:0x6000001c5af0.width == _UIOLAGapGuide:0x6000001c5280.width>",
    "<NSLayoutConstraint:0x6000000913a0 UIView:0x7f83b4623b60.leading >= UIView:0x7f83b461d5e0.trailing>"
)

Will attempt to recover by breaking constraint 
<MASLayoutConstraint:0x6000000afcc0 UILabel:0x7f83b4623510.right == PageTitle:0x7f83b4623010.right - 20>