iOS Developer Library

Developer

UIKit Framework Reference UIPageViewControllerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIPageViewControllerDelegate

Inheritance


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 5.0 and later.

The delegate of a page view controller must adopt the UIPageViewControllerDelegate protocol. These methods allow the delegate to receive a notification when the device orientation changes and when the user navigates to a new page. For page-curl style transitions, the delegate can provide a different spine location in response to a change in the interface orientation.

  • Called before a gesture-driven transition begins.

    Declaration

    Swift

    optional func pageViewController(_ pageViewController: UIPageViewController, willTransitionToViewControllers pendingViewControllers: [AnyObject])

    Objective-C

    - (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers

    Parameters

    pageViewController

    The page view controller.

    pendingViewControllers

    The view controllers that are being transitioned to.

    Discussion

    If the user aborts the navigation gesture, the transition doesn’t complete and the view controllers stay the same.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.

  • Called after a gesture-driven transition completes.

    Declaration

    Swift

    optional func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers previousViewControllers: [AnyObject], transitionCompleted completed: Bool)

    Objective-C

    - (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed

    Parameters

    pageViewController

    The page view controller.

    finished

    YEStrue if the animation finished; otherwise, NOfalse.

    previousViewControllers

    The view controllers prior to the transition.

    completed

    YEStrue if the user completed the page-turn gesture; otherwise, NOfalse.

    Discussion

    Use the completed parameter to distinguish between a transition that completed (the page was turned) and a transition that the user aborted (the page was not turned).

    The value of the previousViewControllers parameter is the same as what the viewControllers method would have returned prior to the page turn.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns the spine location for the given orientation.

    Declaration

    Swift

    optional func pageViewController(_ pageViewController: UIPageViewController, spineLocationForInterfaceOrientation orientation: UIInterfaceOrientation) -> UIPageViewControllerSpineLocation

    Objective-C

    - (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation

    Parameters

    pageViewController

    The page view controller

    orientation

    The new orientation.

    Return Value

    The spine location.

    Discussion

    Use this method to change the spine location when the device orientation changes, as well as setting new view controllers and changing the double-sided state.

    This method is called only if the transition style is UIPageViewControllerTransitionStylePageCurl.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.