2.26. 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.
In Xcode, go to the File menu and then choose New → New Project...
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-78.
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-77). Once you are done, press Next.
Select where you want to save your project. Once you are done, press the Create button. You have now successfully created your project.
Figure 2-77. Setting the project settings of a page-based app
Figure 2-78. Creating a Page-Based Application ...
Get iOS 6 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.