Inequality Constraint Ambiguity
Asked Answered
N

4

26

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

Noemi answered 8/3, 2014 at 14:52 Comment(0)
D
66

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

Dichromatism answered 10/7, 2014 at 8:24 Comment(2)
you just save my life! this is a very subtle issue to notice!Savell
Wow crazy! This is amazing!Lycaon
B
8

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.

Briannabrianne answered 8/3, 2014 at 15:40 Comment(2)
hi larsacus, thanks for your quick reply. I've tried with your suggestion but it doesn't work :( this is my project: mega.co.nz/… can you help me? thanksNoemi
What exactly did you try?Briannabrianne
R
1

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.

Rombert answered 8/3, 2014 at 15:33 Comment(0)
A
0

First you have to know what you want to do with constraints, please remove greater-than-equal-to constraint that does not make scene with less-than-equal-to constraint. buz view need define width constraint. either apply priority to which constraint play role first (greater-than-equal-to constraint or less-than-equal-to constraint).

Ameba answered 19/12, 2015 at 7:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.