Adding a Background Image and Title

The type of Table view highlighted in this chapter has static cells that you set up in Interface Builder, as I mention in the previous section. However, in this view, everything isn’t static — including two things based on the destination. Those two things are the background image and the title. You have to set those programmatically.

Start by hiding the Utility area and then show the Project navigator (if you have hidden it) by making the appropriate selections in the toolbar. Then select RTMasterViewController.m in the Project navigator.

You may recall from Chapter 6 that the View Controller method you’d use to customize a view at launch time is viewDidLoad, which is the method I’ll have you use here as well.

First, import the headers you need by adding the bolded code in Listing 12-1 to RTMasterViewController.m.

Listing 12-1: Updating the RTMasterViewController Implementation

#import “RTMasterViewController.h”

#import “RTDetailViewController.h”

#import “RTAppDelegate.h”

#import “Trip.h”

Now add the bolded code in Listing 12-2 to the viewDidLoad method in RTMasterViewController.m and delete the commented out code in bold, underline, and italic.

Listing 12-2: Updating viewDidLoad

- (void)viewDidLoad


[super viewDidLoad];

//self.title = @”Road Trip”;

RTAppDelegate* appDelegate = [[UIApplication

sharedApplication] delegate];

self.title = appDelegate.trip.destinationName;

UIImageView* imageView = [[UIImageView alloc]

initWithImage:[appDelegate.trip ...

Get iPad Application Development For Dummies, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.