Page View Controller

A page view controller (UIPageViewController) has one or two child view controllers whose view(s) it displays within its own view. The user can then make a gesture (such as dragging) to navigate, revealing the view of a different view controller or pair of view controllers, analogously to the pages of a book.

Page view controllers were introduced in iOS 5, and are a great addition to the repertoire of built-in view controllers. Before iOS 5, I was accomplishing the same sort of thing in my flashcard apps by means of a scroll view (Chapter 20); the code was complex and tricky. With a page view controller, I was able to make my app’s code far simpler.

To create a UIPageViewController, initialize it with initWithTransitionStyle:navigationOrientation:options:. Here’s what the parameters mean:

transitionStyle:

Your choices are:

  • UIPageViewControllerTransitionStylePageCurl (the old page curls off of, or onto, the new page)
  • UIPageViewControllerTransitionStyleScroll (the new page slides into view while the old page slides out).
navigationOrientation:

Your choices are:

  • UIPageViewControllerNavigationOrientationHorizontal
  • UIPageViewControllerNavigationOrientationVertical
options:

A dictionary. Possible keys are:

UIPageViewControllerOptionSpineLocationKey

The position of the spine (the pivot line around which page curl transitions rotate); relevant only if you’re using the page curl transition. The value is an NSNumber wrapping one of the following:

  • UIPageViewControllerSpineLocationMin ...

Get Programming iOS 6, 3rd Edition 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.