简体   繁体   中英

iOS autolayout - size with less then or equal Inequality constraint ambiguity

I can not understand why following setup gives me the Inequality constraint ambiguity error. The general idea (although simplified in this question) is to pin the View to the top and left, give it fixed height and variable width. Thus, 4 constraints have been added: 3 with equal values (for top, left and height) and 1 with less than or equal. And it gives me that error. Finally, what I am trying to achieve, is to put other new to the right of this View, and specify the spacing between them. So, whenever Left view changes the width, the right View will change the X.

It is ambiguous because your width constraint is ambiguous: a less than or equal constraint is not constraining enough. What you probably want, if I can infer what you are doing correctly, is to set the width constraint to a fixed value that you want initially, and then create an IBOutlet for that constraint, as well as for the Right View's X constraint, and change those programmatically when needed. This way you can programmatically change the width of your Left View, and at the same time update the Right View's X position.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM