2.21. Enabling Paging with UIPageViewController


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.


Use UIPageViewController.


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:


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. ...

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

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