Chapter 16

Creating Page-Based Applications

Apple has introduced a new view controller class to make it easy for you to create page-based applications. Applications typical to this category are e-book/magazine readers. These applications typically present content one page at a time and allow a user to flick through pages by swiping across the screen. With iOS 5 not only do you now have the page view controller class to help you create such applications, but also a new application template specifically suited to this type of application.

In this lesson you learn to use the new Page-Based Application template to create page-based applications.

The PageViewController Class

Whether you decide to use the Page-Based Application template or an empty project to start from, you must use an instance of the new PageViewController class in your application. A page view controller allows users to navigate between view controllers using a specific transition. Navigation between pages generally occurs when the user performs a swipe gesture, although it can also be done programmatically.

The page view controller works in tandem with a data source and a delegate object, which must implement the UIPageViewControllerDataSource and UIPageViewControllerDelegate protocols, respectively. The data source object is called in response to gesture-based page navigation. If the value for this property is nil, gesture-based navigation is disabled.

Instantiation

A page view controller is typically instantiated ...

Get iPhone and iPad App 24-Hour Trainer 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.