4.1. Creating a Project with Storyboards

Problem

In Xcode, you want to create a project that uses Storyboards.

Solution

Choose the Use Storyboard option in the New Project setting dialog (Figure 4-1) and make your app a universal app.

The Use Storyboard option of New Project dialog

Figure 4-1. The Use Storyboard option of New Project dialog

Discussion

If you want to create a project that uses storyboards, simply follow these steps:

  1. In Xcode, select the File menu and then NewNew Project...

  2. In the New Project dialog, make sure the iOS main category is selected and select the Application subcategory under iOS. Once that is done, on the right side, select Single View Application and press Next, as shown in Figure 4-2.

  3. Now select a product name and make sure your app is a Universal app. Apple wants developers to start writing universal apps whenever they can, in order for iPad users to also enjoy the same apps that iPhone and iPod touch users have access to. In this dialog, make sure you have checked the User Storyboards checkbox, as shown in Figure 4-3. After you are done, press Next.

  4. You will now be asked to save your project in a folder. Once you are done, press the Create button (see Figure 4-4) and now you have a project that uses storyboards.

Creating a new application to use storyboards

Figure 4-2. Creating a new application to use storyboards

Using storyboards for a new project

Figure 4-3. Using storyboards for a new project

Saving the storyboard app on disk

Figure 4-4. Saving the storyboard app on disk

Now if you have a look at the files that Xcode has created for you (see Figure 4-5), you’ll notice two files whose names end with .storyboard. Xcode, because this is a universal app, created a storyboard for iPhone and another storyboard for iPad, so you can dictate how you want your app to look on each device family.

Two storyboard files in a universal app

Figure 4-5. Two storyboard files in a universal app

Get iOS 5 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.