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.3. Building Windows

Applications use windows in many different ways. Document windows, like those used by word processors or image viewers, tend to be large, resizable windows that contain only a few user interface elements. Utility windows and inspectors tend to have a lot of controls packed into a small area. Dialog and sheets are often the simplest windows, containing only enough items to ask a simple question and collect an answer from the user.

Interface Builder's drag-and-drop interface should be well suited for building windows. Theoretically, all you need to do is drag some controls into your window and you're good to go. In practice, you also need to make sure the controls are arranged properly in the window, accounting both for your application's needs and the spacing rules set forth in the Apple Human Interface Guidelines. Fortunately for you, Interface Builder includes some useful tricks that make this easy.

In the following Try It Out, you build a window to be used as a modal dialog box or a sheet. A modal window locks out portions of your application's interface until you close that window. Modal dialog boxes block the entire application, whereas sheets block access only to the window in which they're anchored. The window contains a number of controls arranged in a specific layout. The window also includes OK and Cancel buttons that allow the user to dismiss the window. As is often the case with small dialog boxes and sheets, this window will not be resizable. ...

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