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

前端 未结 8 2087
日久生厌
日久生厌 2021-01-30 10:22

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

However, recently after upda

相关标签:
8条回答
  • 2021-01-30 10:44

    ignore that when standard.

    after add it click on constrain (blue line) and inspector to constrain attribute and set it to 0.

    that work for me

    0 讨论(0)
  • 2021-01-30 10:45

    There's actually no way to solve this issue at the mean time

    but the best temporary solution is to add the constraints with zero one by one .

    0 讨论(0)
  • 2021-01-30 10:46

    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)

    0 讨论(0)
  • 2021-01-30 10:47

    While @matt workaround is working, I just want to add on that you can set it to 0.01 and then change it to 0, it won't change to the standard value again. Note: Xcode 11.3

    0 讨论(0)
  • 2021-01-30 10:47

    Still experiencing this bug (Xcode 11.3.1). Fixed it by simply adding the constraints as "standard", then clicking on the blue constraint lines and setting the "constant" under size inspector to 0.

    0 讨论(0)
  • 2021-01-30 10:51

    As of Xcode 11.3.1:

    The neatest and fastest solution I've found is as follows:

    Simply type in -0 into the constraint field. Xcode appears to discard the negative and it behaves correctly, which is better than it reading 0.01 for everything.

    You can insert all constraints at once, without having to do one at a time or go and edit later.

    Xcode displays the values as this

    It does seem like really dumb behaviour. Is there a reason that Apple might have made it do this deliberately...?

    Edit: This doesn't seem to work every time, which is frustrating. I've just had a UIImageView show 0 to Superview, yet still visually be at the default value (20). This really does seem like a bug with the IB as the behaviour is totally illogical.

    Edit 2: Seems to be fixed now - phew!

    0 讨论(0)
提交回复
热议问题