Xcode 4 and Interface Builder: editing the vertical distance limit (top of the anchor, not bottom)

I have a widget that does not display correctly on the device (its appearance is OK in IB, but this is not entirely correct). A widget is a shortcut and its location near the middle of the screen. The Builder interface gave it a vertical spatial constraint with a "bottom anchor". Here below is the bottom of the screen (not the widget below or snapping to the top screen).

I am in the inspector, but I don’t see how to go to the top anchor (preferably the widget above). I tried reading Apple docs and Editing restrictions , in particular, but it was confusing and did not explain how to make changes (or I skipped the discussion - there were 7 suggestions).

Shown below is a screen capture in the Builder interface showing a vertical spatial constraint tied to the bottom of the screen. And its attributes leave much to be desired - equal, permanent and priority do not help.

enter image description here

Does anyone know how to edit restrictions? In particular, I want (1) to change the vertical spacer anchor from bottom to top; and (2) snap to the widget above, and not to the top of the screen.

+8
ios cocoa-touch xcode interface-builder xib
source share
2 answers

Select the "Embedded" and "Calculated" elements together by clicking on the button.

With these two items selected, use the restrictions menu:

enter image description here

This menu, as well as the careful selection of items, is central to the happy editing of restrictions in IB. In your case, select the central element, the "Pin" menu. Select "Vertical Spacing" - this will create a new restriction on the vertical distance between the two elements. Alternatively, select one item and click "Top Observation Space" to bring it up, not down.

Now you can select and delete vertical spaces at the bottom of the view. IB will not allow you to remove this sooner since you must have a complete, unambiguous set of restrictions. After adding a new vertical distance limit, you now have this.

To illustrate further, here is an empty view controller with one text field that I dragged:

enter image description here

All restrictions are purple, which means that IB has added them for me (these are system restrictions), and they cannot be removed - these are the minimum restrictions necessary for the placement and size of the text field.

Now I will select the text box and attach the top space to the super-verb:

enter image description here

Now you can see that two restrictions of the vertical space have changed to blue (now they are limited by the user), and they have a thicker appearance in the editor. This means that one of them can be deleted. I select the restriction for the lower space and delete delete:

enter image description here

Note that this still looks like a user restriction - but if I try to remove it, IB will automatically recreate the binding of the system restriction to the bottom of the supervisor, returning us to the square.

I wrote about this and similar startup themes here .

+32
source share

I got one word for Autolayouts. If it works, it works, but if it doesn't, use the old-fashioned way (use the code)

-one
source share

All Articles