Xcode 11 add new constraints set zero: use set value instead of default / standard

Eddie picture Eddie · Dec 20, 2019 · Viewed 8.2k times · Source

I used to use autolayout add new constraints to make simple constraints to superview / relative view like this (for loooong time):

enter image description here

However, recently after updated to the latest xcode (11.3.3 or just 11.3/11C29), I have this weird issue: when I set the constant = 0, they always generate the constraints in an unwanted way like this:

enter image description here

And it seems default value is somehow 20 and making my view look so wrong (0 compared to 20?)

If I fix that by edit the constraint like this:

enter image description here

Then it'll correct again (the image is after edited the constraints, before edited it display constant = Standard)

I don't even know how to describe the issue, but how do I fix this new add new constraint to use my desire point instead of standard / default?

Update:

It seems to only happened when constraint to superview. No clue how to fix tho.

Update Apr-01-2020:

Xcode11.4 fixed this.

Answer

matt picture matt · Dec 24, 2019

Seems like a bug (don't forget to file with Apple). Here's a simple workaround:

When you fill in the number in the "popover", instead of typing 0, type 0.01. This will prevent the number from changing mysteriously to "Standard". Okay, so 0.01 is not the same as 0 but it's close enough that you can't tell the difference, and at least you don't have to go back and change it later.

EDIT Apple says that this bug will be fixed in Xcode 11.4:

Fixed a bug that prevented entering a 0 constant in the constraint popup editors. (54076090)