2.4. User Interface Elements

Upon opening an Interface Builder template, you'll be presented with a window resembling the iPhone's screen, a smaller document window representing the logical class properties and relationships to different objects, and a library of different UI elements available on the iPhone. From here, use the library window to drag graphical elements directly onto the iPhone window. You'll be able to design the view you'd like to build by dragging and resizing elements. You can change their sizes and adjust their placements with the mouse. Descriptions for each UI element are provided, as shown in Figure 2-2.

Figure 2-2. Interface Builder library


The library is arranged according to element category, and different types of elements can be applied only to certain objects. The types of categories follow.

2.4.1. Controllers

Controller objects are view controller classes that manage data view objects (described next). You can create different view controllers in Interface Builder to manage navigation, individual data views, tab bars, tables, or other elements. A view controller cannot be part of an existing view, so to create these types of objects, drag the element into your document window (that's the smaller window containing the File's Owner and First Responder properties). This will create a new window for the controller where you can drag additional UI elements.

2.4.2. Data Views

Data views are individual view classes that display information to the user. These include text views, image viewers, web views, and many other types of objects. A data view is managed by its view controller, which can render multiple data views and link the view it is displaying with your underlying data. You can add as many data views as you like to an existing view, using the guides to position and size them to your liking. Data views can also contain controls and navigation items.

Any objects added to a data view will appear only in that view. For example, a navigation bar added to the view controller will remain visible as the user transitions between views belonging to the view controller, but a navigation bar added to the data view will be visible only when that specific view is displayed.

2.4.3. Inputs and Values

Whenever a user needs to provide some type of input, an input object is used. These are commonly referred to as controls (not to be confused with the controllers mentioned earlier), and include switches, text boxes, segmented controls, and other objects you'll learn about in Chapter 10. You can add a control to any view, and that view will generally handle the events generated when the control is used.

2.4.4. Windows, Views, and Bars

In addition to controllers and data views, you can add additional window, view, and bar objects to an existing view. For example, to add a search bar so that it is visible exclusively within a given view, drag it onto your standard view class instead of a controlling view. You'll learn how to interact with search bars and similar objects in Chapter 10.