Container Views for iOS Apps - dummies

By Neal Goldstein, Dave Wilson

Container views are a technical (Apple) term for content views that do more than just lie there on the screen and display your controls and other content. The UIScrollView class, for example, adds scrolling without you having to do any work.

Most of the time, Container views just do their thing in the background (as part of other views you use — Table views, for example), and usually you won’t need to use or manage them explicitly.

UITableView inherits this scrolling capability from UIScrollView and adds the ability to display lists and respond to the selections of an item in that list. Think of the Contacts application on your iPad (and a host of others, come to think of it). UITableView is one of the primary navigation views on the iPad.

Table views are used a lot in iPad applications to do these two things:

  • Display hierarchal data: For an example, think of the Music application, which gives you a list of albums and, if you select one, a list of songs.

  • Act as a table of contents: Now, think of the Settings application, which gives you a list of applications that you can set preferences for. When you select one of those applications from the list, it takes you to a view that lists what preferences you’re able to set as well as a way to set them.

Another Container view, the UIToolbar class, contains button-like controls, which you find everywhere on the iPad. In the Mail app, for example, you tap an icon on the bottom toolbar to respond to an e-mail.

In this example app called RoadTrip, you find such controls at the top of the Map view (refer to the figure) to allow you to decide on how you want the map to be displayed.

Preview of the app RoadTrip on an iPad