Creating the Table View
Although powerful, Table views are surprisingly easy to work with. To create a Table view, there are only four — count ’em, four — steps, in the following order:
1. Create and format the view itself.
This includes specifying the Table style and a few other parameters, most of which you do in Interface Builder.
2. Specify the Table View configuration.
Not too complicated, actually. You let
UITableView know how many sections you want, how many rows you want in each section, and what you want to call your section headers. You do that with the help of the
tableView:titleForHeaderInSection: methods, respectively.
3. Supply the text (or graphic) for each row.
You return that from the implementation of the
tableView:cellFor RowAtIndexPath: method. This message is sent for each visible row in the Table view, and you return a Table View cell to display the text or graphic.
4. Respond to a user selection of the row.
You use the
tableView:didSelectRowAtIndexPath: method to take care of this task. In this method, you can create a view controller and push it onto the stack (as the storyboard does in a segue), or you can even send a message to the controller that presented a Modal View controller (or any other object).
The data source ...