O'Reilly logo

Beginning Mac OS® X Programming by Drew McCormack, Michael Trent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.4. Making Windows Resizable

When designing windows, you need to consider what will happen when the user tries to resize them. For some windows, such as simple sheets and dialog boxes, you may choose to prohibit resizing. But most user-friendly interfaces allow the user to resize windows as they see fit.

An interface element normally responds in two possible ways when a window is resized. The element may remain stationary, fixed in an area of the screen, or the element may change size along with the window. Some elements may do both: remain fixed vertically and resize themselves horizontally. Interface Builder provides tools for defining what happens to its contents when a window is resized.

In the following Try It Out, you build a simple resizable Cocoa window. Figure 4-26 shows the window in two sizes. Don't worry too much about what this interface is supposed to represent; it's really just an opportunity to practice item layout.

Figure 4.26. Figure 4-26

4.4.1.

4.4.1.1. Try It Out: Building a Resizable Cocoa Window
  1. In Interface Builder, create a new Cocoa Empty project. Your nib window appears.

  2. Drag a Window item from the Windows palette into your nib's Instances tab. An instance named Window is added to your nib file and a blank window representing that instance appears.

  3. Choose ToolsShow Inspector to open the Inspector. The Inspector displays the settings for the new window. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required