How to Set Up Your Custom View Controller for the iPad - dummies

How to Set Up Your Custom View Controller for the iPad

By Jesse Feiler

Although MasterViewController already actually does something in your iOS app, you may want to develop it for use in your app by customizing its appearance and having it display (through its entries or cells) a table of contents showing the app functionality. Here’s how you’d start things off:

  1. In the Project navigator, select Main_iPad.storyboard.

  2. In the Document outline, select Master View Controller – Master in the Master View Controller – Master scene, open the disclosure triangle next to the Master View controller in the scene, and select the Table view.

  3. Using the Inspector selector bar, open the Attributes inspector in the Utility area.

    You’ll notice that, in the Table View section of the Attributes inspector, the Static Cells option is selected in the Content drop-down menu.

    Static cells are used when you know in advance what needs to be displayed in a cell. Instead of having to implement a method in your view controller and return the cell with the text you want, you can format the cells in the storyboard.

    image0.jpg

  4. In the Document outline, open the disclosure triangle next to the Table view, select Table View Section, and delete it.

    You could’ve left that cell and added cells to that section and more sections, but this is what it’s like to start from a clean slate.

    Notice that the segue to the Test Drive controller has been deleted as well. That means you can no longer select Test Drive and have the view slide into place.

You are now ready to add the text you want displayed to the cells.

Table views require both a data source as well as a delegate. The data source supplies the content for the Table view and provides the content for each cell (or row). The delegate manages the appearance and behavior of the Table view and determines what to do when the user selects a cell (or row) — it could, for example, push a view controller onto the stack.