Search code examples
iosautolayoutxcode7.3

Autolayout constant for Equal width constraint setting to negative value


I have designed a simple view with some text fields, label and button, For my text field i have added a Equal Width Constraint for wC and h Any. But my xCode is showing up orange asking it to set to -60 value for constant, Can someone please help understand what does the negative value infer to and how does xCode suggest this value. Please see screen shot below.

Note :- my view looks fine with both adding 60 and -60.

Thanks enter image description here


Solution

  • That is not a suggestion for your constant, rather it is indicating a misplaced view. Most probably you added some sort of constraint, but the UI did not update on the xib/storyboard file (which is quite normal).

    It's basically Xcode's way of telling you, "Hey, even though the view looks like this in your layout, when it actually renders it will be 60 points smaller in width." To fix it in IB, simply select the affected view and go to Editor -> Resolve Auto Layout Issues -> Update Frames and the view should update accordingly.

    If on the other hand you want the view when rendered to look exactly as is, choose Editor -> Resolve Auto Layout Issues -> Update Constraints on the affected view instead.