Online Book Reader

Home Category

Learn Objective-C on the Mac - Mark Dalrymple [49]

By Root 958 0
” When you see that it’s filled in the full text as “NSAddTemplate,” press Enter and you’ll see that your new button now has a “+” image. Resize the button horizontally so that it is just wide enough to contain the image, then duplicate the button (with ⌘D) to make another button. Select this second button, go back to the Image combo box in the Attributes Inspector again, and begin typing “nsremovetemplate,” which will provide you with a “-” image in your button.

Now, take the “add” button, and drag it to a point just below the bottom edge of the table view, using the blue guidelines to make its left edge line up with the left edge of the table view, and its top edge the recommended distance from the table view’s bottom edge. Drag the “remove” button into location just to the right of the “add” button. Then, select both buttons and the table view by dragging a selection rectangle over all of them, and choose Layout➤Embed Objects In➤Box from the menu, then set the title of the new box to “Big List o’ Villains”. Your newest views are now all contained inside an NSBox, just like the rest (except that it’s not yet properly sized or aligned with anything). Figure 5-3 shows what you should be seeing at this point.

Figure 5-3. The table view and its buttons are in place, but not yet resized.

Tweaking the Autosizing Characteristics


Now let’s make the table view and its surrounding box fill up that space. Grab the new box and position it so that its bottom edge is aligned with the bottom of the Notes box, and its left edge is the correct distance from the left edge of the window. Then grab its upper right-hand resize handle, and drag it up and to the right so that its upper and right-hand edges are the correct distances from the top of the window and the boxes to its right, respectively. As usual, the blue guidelines will help make this happen.

Now select the table view inside its box, and resize it using the upper-right resize handle so that it fills the box to the top and the right. See Figure 5-4 to get an idea of what you’re shooting for.

In Chapter 4, we configured our boxes so that the Notes box would resize fully with the window, while everything else remained stuck to the upper left. Now that we have a table view on the left, we’re going to reconfigure the resizing behavior of our boxes so that the table view resizes fully with the window, the Notes box resizes vertically (while keeping the same width), and everything else sticks to the upper right.

Start by selecting the table view. Open the Size Inspector (⌘3), and in the Autosizing section, click on each of the dashed red lines (both inside and outside the black box) to make them solid. The solid lines inside the black box configure it to resize in both dimensions, and the solid lines outside the black box make sure that its external margins (relative to the view it’s in) will remain the same. In other words, the table view will resize fully in both dimensions as its parent view is resized. Next, select the “Big List o’ Villains” box itself by clicking its title, and give it the same treatment, so that it will resize fully with the window. Figure 5-5 shows what this configuration looks like in the Autosizing section of the Attributes Inspector.

Figure 5-4. This is how we want the window to look.

Figure 5-5. These Autosizing settings for both the table view and its enclosing box will allow them to resize fully with the window.

Now select the “Notes” box, and change its Autosizing configuration so that it still resizes vertically, but no longer resizes horizontally, and allows its left-hand margin to be flexible (to leave room for the resizing table view). Do this by making the inner horizontal line and the left margin red line dashed, while leaving the other red lines solid, as shown in Figure 5-6.

Figure 5-6. These Autosizing settings for the box containing the “notes” text-view will make it resize the way we want it to.

Now it’s time to take care of all the other boxes on the right side (everything above the Notes box). For each

Return Main Page Previous Page Next Page

®Online Book Reader