Chapter 6. Using UITableView
In This Chapter
Exploring the methods of a UITableView |
Learning how a UITableView accesses data from your model without being tightly coupled to it |
Implementing a delegate and data source for a UITableView |
Expanding the sample application to use a UITableView |
The application example in the previous chapter got the job done, but it was certainly not an example of an elegant user interface. It was useful to demonstrate some of the intricacies of UIViewController
, but if you consider the type of data that you were working with (a list of cities), then it's easy to recognize that a different kind of user interface might be more effective at navigating this data. Fortunately for you, there is another type of view that is uniquely suited to lists of data. That view is a UITableView
, and it is this view that you will focus on now.
Table views are not new in the realm of GUI toolkits. On the iPhone, however, because of its small screen size, there are a variety of constraints that make it impossible to implement a traditional table view with rows and columns. Instead, Apple provides the UITableView
, which can be used to display a variety of list-oriented data. One way to think of the UITableView
is in terms of representing a single-column subset of your data, but it can also be used to represent hierarchical data. In this chapter, you'll see how to display your favorite cities as a list in a UITableView
.
Understanding UITableView Data Sources and Delegates
The first ...
Get Cocoa Touch™ for iPhone® OS 3 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.