Reputation: 2230
I'm creating my auto layout constraints in code, using Masonry, in updateConstraints
:
I get the following in the console log:
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)
(
"<NSLayoutConstraint:0x7f8eabc684e0 Demo.View1:0x7f8eabc34680.top == Demo.View2:0x7f8eabc3ef20.bottom + 10>",
"<MASLayoutConstraint:0x7f8eabc39420 Demo.View1:0x7f8eabc34680.top == Demo.View2:0x7f8eabc3ef20.bottom + 40>"
)
Will attempt to recover by breaking constraint
<MASLayoutConstraint:0x7f8eabc39420 Demo.View1:0x7f8eabc34680.top == Demo.View2:0x7f8eabc3ef20.bottom + 40>
Why it didn't update the constraint?
Update:
BTW: I'm using the storyboard.
Upvotes: 0
Views: 1681
Reputation: 660
You didn't show us your constraints so it's hard to tell what is wrong.
I am not sure why but you can't update constraints with relative values like multipliedBy. What you can do is update constraints to a constant. And the constant you can calculate relative to screen size. Like so:
_height_y = -self.view.frame.size.height*0.25;
[_phoneField updateConstraints:^(MASConstraintMaker *make) {
make.baseline.equalTo(self.view.centerY).with.offset(_height_y);
}];
Upvotes: 0
Reputation: 17381
Good advice from the error message here
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.
and helpfully printed out
"<NSLayoutConstraint:0x7f8eabc684e0 Demo.View1:0x7f8eabc34680.top == Demo.View2:0x7f8eabc3ef20.bottom + 10>"
"<MASLayoutConstraint:0x7f8eabc39420 Demo.View1:0x7f8eabc34680.top == Demo.View2:0x7f8eabc3ef20.bottom + 40>"
Note the similarity between the two constraints and object references
The top of view1
should be below the bottom of view2
by 10 or 40 . Cant be both so which one ? As you are using Masonry
I suspect its the MASLayoutConstraint
one you want.
Figure out where the NSLayoutConstraint
is coming from. Its not an autoresizing one as they have squiggles in them. So either you put it there in your code or it came from a XIB/Storyboard.
You can use the regex find in Xcode to make it easier if its the former. I might try this.
Hit the disclosure by the search icon. You can insert various patterns.
I might use this as a starter
Upvotes: 2