iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UIPageViewController Class Reference

Options
Deployment Target:

On This Page
Language:

UIPageViewController

A page view controller lets the user navigate between pages of content, where each page is managed by its own view controller object. Navigation can be controlled programmatically by your app or directly by the user using gestures. When navigating from page to page, the page view controller uses the transition that you specify to animate the change. More...

Inheritance


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 5.0 and later.
  • Sets the view controllers to be displayed.

    Declaration

    Swift

    func setViewControllers(_ viewControllers: [AnyObject]!, direction direction: UIPageViewControllerNavigationDirection, animated animated: Bool, completion completion: ((Bool) -> Void)!)

    Objective-C

    - (void)setViewControllers:(NSArray *)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

    YEStrue if the animation finished; NOfalse 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

    YEStrue

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

    UIPageViewControllerSpineLocationMin or UIPageViewControllerSpineLocationMax

    YEStrue

    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

    NOfalse

    Pass the front of the page to be displayed.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

    See Also

    viewControllers

  • The view controllers displayed by the page view controller. (read-only)

    Declaration

    Swift

    var viewControllers: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *viewControllers

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • An array of UIGestureRecognizer objects that are configured to handle user interaction. (read-only)

    Declaration

    Swift

    var gestureRecognizers: [AnyObject] { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *gestureRecognizers

    Discussion

    These gesture recognizers are initially attached to a view in the page view controller’s hierarchy. To change the region of the screen in which the user can navigate using gestures, they can be placed on another view.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Orientations for page-turn transitions.

    Declaration

    Swift

    enum UIPageViewControllerNavigationOrientation : Int { case Horizontal case Vertical }

    Objective-C

    enum { UIPageViewControllerNavigationOrientationHorizontal = 0, UIPageViewControllerNavigationOrientationVertical = 1 }; typedef NSInteger UIPageViewControllerNavigationOrientation;

    Constants

    • Horizontal

      UIPageViewControllerNavigationOrientationHorizontal

      Horizontal orientation, with pages turning left and right.

      Available in iOS 5.0 and later.

    • Vertical

      UIPageViewControllerNavigationOrientationVertical

      Vertical orientation, with pages turning up and down.

      Available in iOS 5.0 and later.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Directions for page-turn transitions.

    Declaration

    Swift

    enum UIPageViewControllerNavigationDirection : Int { case Forward case Reverse }

    Objective-C

    enum { UIPageViewControllerNavigationDirectionForward, UIPageViewControllerNavigationDirectionReverse }; typedef NSInteger UIPageViewControllerNavigationDirection;

    Constants

    • Forward

      UIPageViewControllerNavigationDirectionForward

      Navigation to the next page.

      Available in iOS 5.0 and later.

    • Reverse

      UIPageViewControllerNavigationDirectionReverse

      Navigation to the previous page.

      Available in iOS 5.0 and later.

    Discussion

    For horizontal navigation, pages turn from the right side of the screen to the left as you navigate forward.

    For vertical navigation, pages turn from the bottom of the screen to the top as you navigate forward.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Styles for the page-turn transition.

    Declaration

    Swift

    enum UIPageViewControllerTransitionStyle : Int { case PageCurl case Scroll }

    Objective-C

    enum { UIPageViewControllerTransitionStylePageCurl = 0 UIPageViewControllerTransitionStyleScroll = 1 }; typedef NSInteger UIPageViewControllerTransitionStyle;

    Constants

    • PageCurl

      UIPageViewControllerTransitionStylePageCurl

      Page curl transition style.

      When the page curl transition style is specified, the page view controller displays a page-turning animation when transitioning between view controllers. If a data source is specified, the animation follows the user’s finger during a navigation gesture.

      Available in iOS 5.0 and later.

    • Scroll

      UIPageViewControllerTransitionStyleScroll

      Scrolling transition style.

      When the page scrolling style is specified, the page view controller displays a page-scrolling animation when transitioning between view controllers. If a data source is specified, the animation follows the user’s finger during a navigation gesture.

      Available in iOS 6.0 and later.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Keys for the options dictionary.

    Declaration

    Swift

    let UIPageViewControllerOptionSpineLocationKey: String let UIPageViewControllerOptionInterPageSpacingKey: String

    Objective-C

    NSString * const UIPageViewControllerOptionSpineLocationKey; NSString * const UIPageViewControllerOptionInterPageSpacingKey;

    Constants

    • UIPageViewControllerOptionSpineLocationKey

      UIPageViewControllerOptionSpineLocationKey

      Location of the spine.

      For possible values, see Spine Locations. A spine location is only valid if the transition style is UIPageViewControllerTransitionStylePageCurl.

      If the transition style is UIPageViewControllerTransitionStylePageCurl, the default value for this property is UIPageViewControllerSpineLocationMin; otherwise, the default is UIPageViewControllerSpineLocationNone.

      Available in iOS 5.0 and later.

    • UIPageViewControllerOptionInterPageSpacingKey

      UIPageViewControllerOptionInterPageSpacingKey

      Space between pages, in points.

      The value should be a CGFloat wrapped in an instance of NSNumber. The default value is zero. An inter-page spacing is only valid if the transition style is UIPageViewControllerTransitionStyleScroll.

      Available in iOS 6.0 and later.

  • Locations for the spine.

    Declaration

    Swift

    enum UIPageViewControllerSpineLocation : Int { case None case Min case Mid case Max }

    Objective-C

    enum { UIPageViewControllerSpineLocationNone = 0, UIPageViewControllerSpineLocationMin = 1, UIPageViewControllerSpineLocationMid = 2, UIPageViewControllerSpineLocationMax = 3 }; typedef NSInteger UIPageViewControllerSpineLocation;

    Constants

    • None

      UIPageViewControllerSpineLocationNone

      No spine.

      This spine location is not valid if the transition style is UIPageViewControllerTransitionStylePageCurl.

      Available in iOS 5.0 and later.

    • Min

      UIPageViewControllerSpineLocationMin

      Spine at the left or top edge of the screen.

      One view controller is displayed at a time.

      Available in iOS 5.0 and later.

    • Mid

      UIPageViewControllerSpineLocationMid

      Spine in the middle or the screen.

      Two view controllers are displayed at a time.

      Available in iOS 5.0 and later.

    • Max

      UIPageViewControllerSpineLocationMax

      Spine at the right or bottom edge of the screen.

      One view controller is displayed at a time.

      Available in iOS 5.0 and later.

    Discussion

    To set the spine location, wrap one of these constants in an NSNumber object and set it as the value for the UIPageViewControllerOptionSpineLocationKey key in the options dictionary passed to the initWithTransitionStyle:navigationOrientation:options: method.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.