Cover by Vandad Nahavandipoor

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

2.21. Enabling Paging with UIPageViewController

Problem

You want to create an app that works similarly to iBooks, where the user can flip through the pages of a book as if it were a real book, to provide an intuitive and real user experience.

Solution

Use UIPageViewController.

Discussion

Xcode has a template for page view controllers. It’s best to first see how they look before reading an explanation of what they actually are. So follow these steps to create your app to use page view controllers:

Note

Page view controllers work both on the iPhone and the iPad.

  1. In Xcode, go to the File menu and then choose NewNew Project...

  2. On the lefthand side of the New Project window, make sure you’ve selected iOS and then Application. Once that is done, pick the Page-Based Application template from the right side and press Next, as shown in Figure 2-67.

    Creating a Page-Based Application in Xcode

    Figure 2-67. Creating a Page-Based Application in Xcode

  3. Now select a product name and make sure the Device Family that you’ve chosen is Universal, as you normally would want your app to run on both the iPhone and the iPad (see Figure 2-68). Once you are done, press Next.

    Setting the project settings of a page-based app

    Figure 2-68. Setting the project settings of a page-based app

  4. Select where you want to save your project. Once you are done, press the Create button. You have now successfully created your project. ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required