Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inequality Constraint Ambiguity

i've a problem in resizing a UIView with Autolayout and constraints. I'd like to change the origin (less than or equal of original) and the width (greater than or equal of original) but I got this: Inequality Constraint Ambiguity

Do you have idea for solve this?

thanks

view error

constraints error

like image 850
Luca T Avatar asked Mar 08 '14 14:03

Luca T


3 Answers

I tried to make more than 1 vertical spacing constraint shrink for 3.5" displays, so I had to make 2 constraints between components that I wanted to shrink on smaller screen. One constraint was inequality (greater or equal) where I specified minimum required size, with 1000 priority, other constraint was equality constraint with specific size that is suitable for 4" screen, but with lower priority of 250.

This way Xcode stopped complaining and layout repositioned properly on smaller screen.

enter image description here

like image 115
frin Avatar answered Nov 15 '22 07:11

frin


Your view is horizontally ambiguous. You do not have enough horizontal constraint information for the system to come up with just one solution for your view heirarchy. In this instance, it can't determine what the view size or left margin needs to be based on the current constraint information.

You need to add a less-than-required-priority (<1000) constraint either to your view's width giving it a defined width or add an equality constraint to your left margin constraint. By making the new constraint a <1000 priority, it will enable the new constraint to properly mix with your existing inequality constraints (which are required constraints). Here is another question that is similar to yours relating to inequalities.

The view will size differently depending on if you add the new constraint to the view's width or the view's left margin. This all depends on how you want your layout to behave in response to changes.

like image 42
larsacus Avatar answered Nov 15 '22 06:11

larsacus


This does not make sense to the compiler (and logically) because there is no way to know whether the program should change x or width. Making one of the two static will solve your problem.

like image 25
Mika Avatar answered Nov 15 '22 05:11

Mika