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 ...
-
-
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access