Chapter 3. Custom Table Views

WHAT'S IN THIS CHAPTER?

  • How to design a custom Table view cell in Interface Builder

  • How to incorporate your custom Table view cell into the standard Table view

  • How to load a property list file into a custom Table view

One of the biggest challenges with mobile devices is presenting data logically, efficiently, and clearly. The most common form of display on mobile devices is the Table view, which is a single-column list of many rows of data. iOS 4 offers a standard Table view that can be plain, indexed, or grouped.

However, sometimes you want the cells to have a different look than those offered by Apple. This chapter shows you how to customize the Table view cell, to give your Table view application its own look and feel.

TABLE VIEWS

Simply put, Table views display information in the form of a list. Determining how data is displayed in a Table view depends on two methods:

  • numberOfSectionsInTableView — Determines the number of grouped sections that exists. For a plain list, there is only one section.

  • tableView:numberOfRowsInSection: — Informs the Table view how many rows are contained in each section

Putting information into each Table view cell is the responsibility of the tableView:cellForRowAtIndexPath: method, where the indexPath contains the section, [indexPath section], and row values, [indexPath row].

When the user chooses a particular Table view cell, the tableView:didSelectRowAtIndexPath: method handles the selection.

If your application supports removing ...

Get Professional iPhone® and iPad™ Application Development 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.