In iOS 7, how do you access the topLayoutGuide / bottomLayoutGuide in Interface Builder?

14,823

Just realized that my storyboard was still set to XCode 4.6

You have to go to the File Inspector (icon that looks like a file icon in the right navigation panel in Xcode) and then under "Interface Builder Document" where it says "Opens in" change to Default (5.0) and / or "View as" iOS 7.0 and Later

Then your IB document will show the guides inside the left hand navigation panel under the view controller

enter image description here

Often if you select the view, and click the "Pin" button at the bottom right, pin the vertical spacing, and the dropdown will have an option to use the topLayoutGuide

In my Storyboard, was still have trouble getting my UITableView to pin the vertical spacing between the top of the table view and the top layout guide. Every time I control-dragged I would get it pinning to the bottom of the table view instead of the bottom. But then I tried manually dragging the table view so that it appeared below the nav bar in IB and then control-dragged and the vertical spacing finally worked.

Share:
14,823
shim
Author by

shim

Delphia

Updated on June 19, 2022

Comments

  • shim
    shim almost 2 years

    Using XCode 5, downloaded today. iOS 7. When I run app the table view header appears underneath the navigation bar, I don't mind it scrolling underneath the navbar but I'd like for it to appear unobstructed initially. I am trying to figure out how to use the topLayoutGuide mentioned in the iOS 7 transition guide, which says you can set a constraint relative to it, but doesn't explain how.

    Anyone know?

    Transition guide here: http://tinyurl.com/mgdl4sg

  • shim
    shim over 10 years
    However, every time I try to add a constraint to the vertical spacing between my table view and the top layout guide, for some reason interface builder sets it so the spacing is constrained between the bottom of the table view, and not the top. Seems like a bug?
  • user276641
    user276641 over 10 years
    The offered pin seems to be affected by which way you control drag, drag down and it pins downwards.
  • Dean Davids
    Dean Davids over 10 years
    Does this only work in storyboards? I do not see those guides in xib.
  • shim
    shim over 10 years
    Yes, appears to be only in storyboards, and maybe not for every type of view controller
  • shim
    shim over 10 years
    You can, you just need to adjust the constraints.