Tables and Embedded Controls

A table in Cocoa Touch represents a vertical list of items, with each item assigned to a cell or row in the table. If the list of items is multi-dimensional, such as a list of email messages in the Mail application, each table cell should display a succinct summary, label, or other high-level indication of the object assigned to the cell. Users can get additional information for each row by tapping the row. When a user taps the row, an event is sent to the delegate of the table, which is an object that conforms to the UITableViewDelegate protocol. This protocol defines methods for handling interaction with cells. A table delegate defines the methods it wishes to handle, and the table controller automatically handles the communication between the user interface and the delegate. (The availability of free implementations of design patterns like the delegate pattern is one of the benefits that Cocoa Touch controller classes offer developers.)

You can embed UIControl instances in table cells to add functionality within the context of a single row in your dataset. For example, users will often need to delete a record using a button, as with the Mail application, or change the order of rows in a table. The table delegate protocol, UITableViewDelegate, allows developers to handle user-initiated edits like reordering, deletion, and insertion of new rows into the table.

The controls you use in table cells should be chosen with attention to the interactive nature ...

Get Programming the iPhone User Experience 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.