Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add constraint not listed in Editor menu in Xcode

Tags:

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??

like image 434
Sean Danzeiser Avatar asked Dec 21 '12 00:12

Sean Danzeiser


People also ask

How do you add constraints in XCode?

To create constraints select the button and click the Align icon in the auto layout menu. A popover menu will appear, check both “Horizontal in container” and “Vertically in container” options to center the button on the screen. Then click the “Add 2 Constraints” button. Run the application.

How do you add constraints in storyboard IOS?

Open the Align menu with the yellow button selected and check Horizontally in Container, then click Add 1 Constraint. Now, select both buttons at the same time using the Shift key and, in the Align menu, check Leading Edges. Again, actually install the constraint by clicking Add 1 Constraint.


1 Answers

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

like image 117
Rob Avatar answered Oct 07 '22 20:10

Rob