Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Use Standard Value grayed out in Storyboard?

I can't figure this out. Could someone tell me why and how to enable "Use Standard Value"?

standard-value-disabled

like image 462
Matt Tang Avatar asked Mar 12 '15 19:03

Matt Tang


1 Answers

The standard value is the "recommended spacing between views"[1]. A constraint that is relative to a margin or safe area already contains this recommended spacing. This is likely why you're seeing the "Use Standard Value" option as disabled.

To enable the "Use Standard Value" option, change the constraint to no longer be relative to a margin or the safe area. You may also need to uncheck "Respect language direction". If the option is still grayed out, try toggling the "Relative to margin" option on and off -- it appears to get stuck sometimes in Interface Builder.

[1] https://help.apple.com/xcode/mac/8.0/#/deve7dfb37c9


Some further observations/background I came across that seemed relevant to understanding the issue:

Prior to Safe Area Layout Guides, we had leading/trailing margins and Top / Bottom Layout Guides:

  • I understood that pinning views to the leading and trailing margins didn't have access to "Use Standard Value" because these margins already provide a standard value from the edges.
  • Top and bottom layout guides, on the other hand, merely indicated where top and bottom edges extended to, excluding navigation bars and status bars etc. Unlike leading and trailing margins, they didn't by default provide a standard distance from these bars etc, so constraints pinned to the Top and Bottom layout guides did have access to "Use Standard Value".

Top and Bottom Layout Guides are now deprecated in favor of Safe Area Layout Guides, which perform a similar function, indicating an area that will not be covered up by UIKit components such as Tab bars, Navigation bars etc. In iOS at least (tvOS seems another story) the safe area doesn't seem to indicate the edge + a standard distance (as leading and trailing margins did). But constraints don't have access to "Use Standard Value" either. (See it grayed out below) This means that if we use Safe Area Layout guides to constrain a view to the edges, we no longer have access to standard distances.

Is this an oversight, or am I missing something?

It also seems extremely buggy, for example:

  • Bug #1 - If you migrate a storyboard to Safe Area Layout Constraints, the top and bottom constraints do seem to have "Use Standard Value" selected (though the "standard value" seems to be 0). If you change to another value, however, there's then no way to return to "Use Standard Value". All very strange!
  • Bug #2 - If you have a good old fashioned leading or trailing constraint pinned to the root view that is set to "Relative to Margin" and you switch to "Safe Area", the "Relative to Margin" option disappears of course, but you cannot "Use Standard Value". HOWEVER - if you turn off "Relative to Margin" before switching to "Safe Area" then "Use Standard Value" is available with Safe Area Layout Margins. I've even encountered situations where I need to turn "Relative to Margin" on and then off again to then be able to "Use Standard Value". That said, this "standard value" seems to be 0, so doesn't seem to be working even if it's selected.[2]

[2] https://forums.developer.apple.com/thread/87028

like image 159
Nate Whittaker Avatar answered Sep 20 '22 19:09

Nate Whittaker