Standard value for Auto Layout constraints

Hello! I am new to iOS development and was walking through UIKit iOS App Dev Tutorial on this website. My problems start every time when I need to set leading horizontal spacing to "Standard" by removing value or selecting it in the dropdown menu. When I try to do that, the value in the field resets to previously set value and "Use Standard value" is greyed out. This is so frustrating!

Even when I download complete project and try to set value myself, it still does not work! Is it an Xcode bug? My version is 13.0 (13A233)

Accepted Reply

So, do it differently:

  • select the table view cell.

  • Control drag from the Text Field to the "Content"

  • You will get the menu to select the leading constraint:

Then in Size Inspector,

  • select the constraint (it will have a value, as 24)
  • Type on Edit in the constraint
  • remove the value.

Standard will appear instead of value.

It's done.

  • It helped me! Thank you very much!

Add a Comment

Replies

If you hover your mouse over the greyed option, you will get an explanation like this:

In some cases there is no standard constraint.

What is the constraint you want to add ? From the object to what ? A good way to add constraint is to control drag from the object to the one you want to set relative constraint and select from the menu.

So explain what you want precisely as constraint, we'll tell how to achieve.

Hello! Thank you very much for responding! I have a text field nested in a table cell and I want it to have standard margins. This is a table cell with all constraints set to 0

This is what I want to achieve (leading and trailing constraints set to Standard)

This is what Add New Constraint window says

So, do it differently:

  • select the table view cell.

  • Control drag from the Text Field to the "Content"

  • You will get the menu to select the leading constraint:

Then in Size Inspector,

  • select the constraint (it will have a value, as 24)
  • Type on Edit in the constraint
  • remove the value.

Standard will appear instead of value.

It's done.

  • It helped me! Thank you very much!

Add a Comment