Contents

setViewControllers(_:direction:animated:completion:)

Sets the view controllers to be displayed.

Declaration

func setViewControllers(_ viewControllers: [UIViewController]?, direction: UIPageViewController.NavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil)

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

    True if the animation finished; False 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 UIPageViewController.TransitionStyle.pageCurl, the view controllers to pass in the viewControllers parameter depends on the spine location and the value of the isDoubleSided property:

Spine location

Double sided

What to pass

Mid

True

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

Min or Max

True

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.

Min or Max

False

Pass the front of the page to be displayed.

See Also

Providing Content