Add constraint not listed in Editor menu in Xcode

Sean Danzeiser picture Sean Danzeiser · Dec 21, 2012 · Viewed 13.1k times · Source

I am trying to add layout constraints to my NIB, and i am following the directions apple provides here:

http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/030-Edit_User_Interfaces/edit_user_interface.html

It says this with regards to adding constraints:

To add a constraint Select the object or objects for which you want to add the constraint.

Choose a constraint from the Editor > Add Constraint menu or an alignment type from the Editor > Alignment menu.

That Add Constraint menu is no where to be found. What gives? How can i add constraints??

Answer

Rob picture Rob · Dec 21, 2012

That documentation is incorrect.

Constraints are added via the buttons in the lower right corner of the Interface Builder workspace in Xcode 4.6:

Xcode 4.6 buttons

The button on the left is for alignment-based constraints, and the middle one (the "I-beam") is for pinning spacing/heights.

In Xcode 5.0, those buttons look a little different, but the features are very similar:

Xcode 5 buttons