UIPageViewControllerDataSource Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 5.0 and later.
Companion guide
Declared in
UIPageViewController.h
Related sample code

Overview

The UIPageViewControllerDataSource protocol is adopted by an object that provides view controllers to the page view controller on an as-needed basis, in response to navigation gestures.

The data source implementation is free to handle this responsibility in any way that is appropriate for your application. In many cases, it should look at the view controller passed to it, determine what content to display, and create the view controllers as they are needed. You may find it helpful to include information such as the page number in the view controller, to simplify the task of determining what content to display.

If both of the methods in “Supporting a Page Indicator” are implemented and the page view controller’s transition style is UIPageViewControllerTransitionStyleScroll, a page indicator is visible. Both of these methods are called after the setViewControllers:direction:animated:completion: method is called. After gesture-driven navigation, these methods are not called. The index is updated automatically and the number of view controllers is expected to remain constant.

Tasks

Providing View Controllers

Supporting a Page Indicator

Instance Methods

pageViewController:viewControllerAfterViewController:

Returns the view controller after the given view controller. (required)

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
Parameters
pageViewController

The page view controller

viewController

The view controller that the user navigated away from.

Return Value

The view controller after the given view controller, or nil to indicate that there is no next view controller.

Availability
  • Available in iOS 5.0 and later.
Declared In
UIPageViewController.h

pageViewController:viewControllerBeforeViewController:

Returns the view controller before the given view controller. (required)

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
Parameters
pageViewController

The page view controller

viewController

The view controller that the user navigated away from.

Return Value

The view controller before the given view controller, or nil to indicate that there is no previous view controller.

Availability
  • Available in iOS 5.0 and later.
Declared In
UIPageViewController.h

presentationCountForPageViewController:

Returns the number of items to be reflected in the page indicator.

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
Parameters
pageViewController

The page view controller.

Return Value

The number of items to be reflected in the page indicator.

Availability
  • Available in iOS 6.0 and later.
Declared In
UIPageViewController.h

presentationIndexForPageViewController:

Returns the index of the selected item to be reflected in the page indicator.

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
Parameters
pageViewController

The page view controller.

Return Value

The index of the selected item to be reflected in the page indicator.

Availability
  • Available in iOS 6.0 and later.
Declared In
UIPageViewController.h