O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CREATING A SIMPLE TABLE VIEW

The best way to understand how to use a Table view in your application is to create a new Single View Application project and then manually add a Table view to the View window and wire it to a View Controller. That way, you can understand the various building blocks of the Table view.

Without further ado, use the following Try It Out to create a new project and see how to put a Table view together!

TRY IT OUT: Using a Table View

image

  1. Create a new Single View Application (iPhone) project and name it TableViewExample. You will also use the project name as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
  2. Select the TableViewExampleViewController.xib file to edit it in Interface Builder.
  3. Drag the Table View from the Object Library and drop it onto the View window (see Figure 8-2).

    image

    FIGURE 8-2

  4. Right-click the Table view and connect the dataSource outlet to the File's Owner item (see Figure 8-3). Do the same for the delegate outlet.

    image

    FIGURE 8-3

  5. In the TableViewExampleViewController.h file, add the following statement that appears in bold:
    #import <UIKit/UIKit.h> @interface TableViewExampleViewController : UIViewController ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required