Bars

As you saw in Chapter 19, the three bar types — UINavigationBar, UIToolbar, and UITabBar — are often used in in conjunction with a dedicated view controller. A UINavigationBar can be used with a UINavigationController (in which case it always appears at the top of the view). A UIToolbar can be used with a UINavigationController (in which case it always appears at the bottom of the view). A UITabBar can be used with a UITabBarController (in which case it always appears at the bottom of the view).

You can also use these bar types independently. In the case of UINavigationBar and UITabBar, it isn’t particularly likely that you would do this. The purpose of a UINavigationBar is usually to let the user navigate between views, and to populate a UINavigationBar, you need a UINavigationItem; it’s very convenient to let this be the navigationItem of a UIViewController and let a UINavigationController take care of the relationship between the two, including the physical display of the UIViewController’s view. Similarly, a UITabBar is a way of letting the user choose between multiple items; those items often correspond to entire views, in which case the overall management is best left to a UITabBarController. Also, these are standard interface items, and you don’t want to use them in a nonstandard way that might confuse the user. Even so, you might encounter a situation in which a full-fledged UIViewController is overkill or somehow doesn’t work properly, and you might then solve the problem ...

Get Programming iOS 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.