Introduction Table views are the most common mechanism used to display lists of data to users, each item in a table's list is a row. iPhone can contains unlimited number of rows, constrained by the amount of available memory. iPhone tables can be only one column. Table views are implemented as class UITableView. Table views are not responsible for storing your table's data, they only store enouth data to draw the rows that are currently visible. Table views get their configuration data from an object that conforms to the UITableViewDelete protocol, and their row data from an object that conforms the UITableViewDataSource protocol. Table view cells are implemented as class UITableViewCell. Each UITableViewCell object can only be configured with an image, some texts, and optional accessory icon. An accessory icon is a small icon on the right side of the rwo.
UITableViewCell
Set text
Text fonts
Image
UITableViewDelegate
Indent level
Row selected event before and after row selected event, in before row selected event, you can configure whether prevent the row to be selected by returing value)
Row height
Section
UITableViewDataSource
How to set delegate and data source
Add table view in Nib
Add delegate and data source outlets in File Owners class
Establish connection to outlet delegate and data source
How To Cumtomize UITableViewCell By default, table view cell only display a single line of text, if you want show multiple lines by specifying a string containing carriage return, table view will remove carriage return, and diaplay the data on a single line. Instead, there are two ways to customize UITableViewCell:
Subclass UITableViewCell
Create a Nib file
Add UITableViewCell into the Nib file
Add some views (UILable ... ) in the cell view in Nib
Create a class inherits from UITableViewCell
Add outlets in UITableViewCell subclass
In Nib file, press Command-4 to bring up identity inspector, then change the class of table view cell to UITableViewCell subclass
Establish outlets connection
When you create table view cell in delegate, use UITableViewCell subclass instead.
Customize UITableViewCell Layout When create UITableViewCell in tabView:cellForRowAtIndex:, create some sub views, set position/size of theses sub views, and then add these sub views to UITableViweCell using contentview:addSubView, you can use tag to identify each sub views.
...
Grouped and Indexed list
...
....
Reference
Beginning iPhone Development: Exploring the iPhone SDK Chapter: Application Settings and User Defaults Page: P186~230