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

TECHNIQUE 2 — CREATING UNIVERSAL APPLICATIONS

The previous technique shows how you can modify the Targeted Device Family setting to create a single application that runs on both the iPhone and the iPad, called a Universal application. The challenge is adapting the UI of the application for each platform — you have to programmatically detect the type of device the application is running on and then modify the layout of the UI dynamically.

Apple recommends that you create a Universal application, one that targets both the iPhone and the iPad, with separate XIB files representing the UI for each platform. The following Try It Out demonstrates how you can create a Universal application.

TRY IT OUT: Creating a Universal Application

image

  1. Using Xcode, create a Single View Application project and name it MyUniversalApp. Ensure that you select Universal for the Device Family (see Figure 5-10). You will also use the project name as the Class Prefix. Ensure that the Use Automatic Reference Counting option is unchecked.

    image

    FIGURE 5-10

  2. Observe that you now have two XIB files (see Figure 5-11) in your project.

    image

    FIGURE 5-11

  3. Select the MyUniversalAppViewController_iPhone.xib file to edit it in Interface ...

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