PageCoordinatorDataSource

open class PageCoordinatorDataSource : NSObject, UIPageViewControllerDataSource

PageCoordinatorDataSource is a UIPageViewControllerDataSource implementation with a rather static list of pages.

It further allows looping through the given pages. When looping is active the pages are wrapped around in the given presentables array. When the user navigates beyond the end of the specified pages, the pages are wrapped around by displaying the first page. In analogy to that, it also wraps to the last page when navigating beyond the beginning.

  • The pages of the UIPageViewController in sequential order.

    Declaration

    Swift

    open var pages: [UIViewController]
  • Whether or not the pages of the UIPageViewController should be in a loop, i.e. whether a swipe to the left of the last page should result in the first page being shown (or the last shown when swiping right on the first page)

    Declaration

    Swift

    open var loop: Bool
  • Creates a PageCoordinatorDataSource with the given pages and looping capabilities.

    Declaration

    Swift

    public init(pages: [UIViewController], loop: Bool)

    Parameters

    pages

    The pages to be shown in the UIPageViewController.

    loop

    Whether or not the pages of the UIPageViewController should be in a loop, i.e. whether a swipe to the left of the last page should result in the first page being shown (or the last shown when swiping right on the first page) If you specify false here, the user cannot swipe left on the last page and right on the first.

  • See UIPageViewControllerDataSource for further information.

    Declaration

    Swift

    open func presentationCount(for pageViewController: UIPageViewController) -> Int

    Parameters

    pageViewController

    The dataSource owner.

    Return Value

    The count of pages, if it is displayed. Otherwise 0.

  • See UIPageViewControllerDataSource for further information.

    Declaration

    Swift

    open func presentationIndex(for pageViewController: UIPageViewController) -> Int

    Parameters

    pageViewController

    The dataSource owner.

    Return Value

    The index of the currently visible view controller.

  • See UIPageViewControllerDataSource for further information.

    This method first searches for the index of the given viewController in the pages array. It then tries to find a viewController at the preceding position by potentially looping.

    Declaration

    Swift

    open func pageViewController(_ pageViewController: UIPageViewController,
                                 viewControllerBefore viewController: UIViewController) -> UIViewController?

    Parameters

    pageViewController

    The dataSource owner.

    viewController

    The viewController to find the preceding viewController of.

    Return Value

    The preceding viewController.

  • See UIPageViewControllerDataSource for further information.

    This method first searches for the index of the given viewController in the pages array. It then tries to find a viewController at the following position by potentially looping.

    Declaration

    Swift

    open func pageViewController(_ pageViewController: UIPageViewController,
                                 viewControllerAfter viewController: UIViewController) -> UIViewController?

    Parameters

    pageViewController

    The dataSource owner.

    viewController

    The viewController to find the following viewController of.

    Return Value

    The following viewController.