Instance Method

setViewControllers:direction:animated:completion:

Sets the view controllers to be displayed.

Declaration

- (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers direction:(UIPageViewControllerNavigationDirection)direction animated:(BOOL)animated completion:(void (^)(BOOL finished))completion;

Parameters

viewControllers

The view controller or view controllers to be displayed.

direction

The navigation direction.

animated

A Boolean value that indicates whether the transition is to be animated.

completion

A block to be called when the page-turn animation completes.

The block takes the following parameters:

finished

YES if the animation finished; NO if it was skipped.

Discussion

The view controllers passed to this method are those that will be visible after the animation has completed. Use a data source to provide additional view controllers to which users navigate.

If the transition style is UIPageViewControllerTransitionStylePageCurl, the view controllers to pass in the viewControllers parameter depends on the spine location and the value of the doubleSided property:

Spine location

Double sided

What to pass

UIPageViewControllerSpineLocationMid

YES

Pass the page to be displayed on the left and the page to be displayed on the right.

UIPageViewControllerSpineLocationMin or UIPageViewControllerSpineLocationMax

YES

Pass the front of the page to be displayed and the back of the previously-displayed page. The back is used for the page turning animation.

UIPageViewControllerSpineLocationMin or UIPageViewControllerSpineLocationMax

NO

Pass the front of the page to be displayed.

See Also

Providing Content

UIPageViewControllerNavigationDirection

Directions for page-turn transitions.

viewControllers

The view controllers displayed by the page view controller.

gestureRecognizers

An array of UIGestureRecognizer objects that are configured to handle user interaction.