EMPageViewControllerDelegate

@objc public protocol EMPageViewControllerDelegate

The EMPageViewControllerDelegate protocol is adopted to receive messages for all important events of the page transition process.

  • Called before scrolling to a new view controller.

    Note

    This method will not be called if the starting view controller is nil. A common scenario where this will occur is when you initialize the page view controller and use selectViewController:direction:animated:completion: to load the first selected view controller.

    Important

    If bouncing is enabled, it is possible this method will be called more than once for one page transition. It can be called before the initial scroll to the destination view controller (which is when it is usually called), and it can also be called when the scroll momentum carries over slightly to the view controller after the original destination view controller.

    Declaration

    Swift

    @objc optional func em_pageViewController(_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController:UIViewController)

    Parameters

    pageViewController

    The page view controller

    startingViewController

    The currently selected view controller the transition is starting from

    destinationViewController

    The view controller that will be scrolled to, where the transition should end

  • Called whenever there has been a scroll position change in a page transition. This method is very useful if you need to know the exact progress of the page transition animation.

    Note

    This method will not be called if the starting view controller is nil. A common scenario where this will occur is when you initialize the page view controller and use selectViewController:direction:animated:completion: to load the first selected view controller.

    Declaration

    Swift

    @objc optional func em_pageViewController(_ pageViewController: EMPageViewController, isScrollingFrom startingViewController: UIViewController, destinationViewController:UIViewController, progress: CGFloat)

    Parameters

    pageViewController

    The page view controller

    startingViewController

    The currently selected view controller the transition is starting from

    destinationViewController

    The view controller being scrolled to where the transition should end

    progress

    The progress of the transition, where 0 is a neutral scroll position, >= 1 is a complete transition to the right view controller in a horizontal orientation, or the below view controller in a vertical orientation, and <= -1 is a complete transition to the left view controller in a horizontal orientation, or the above view controller in a vertical orientation. Values may be greater than 1 or less than -1 if bouncing is enabled and the scroll velocity is quick enough.

  • Called after a page transition attempt has completed.

    Important

    If bouncing is enabled, it is possible this method will be called more than once for one page transition. It can be called after the scroll transition to the intended destination view controller (which is when it is usually called), and it can also be called when the scroll momentum carries over slightly to the view controller after the intended destination view controller. In the latter scenario, transitionSuccessful will return false the second time it’s called because the scroll view will bounce back to the intended destination view controller.

    Declaration

    Swift

    @objc optional func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController:UIViewController, transitionSuccessful: Bool)

    Parameters

    pageViewController

    The page view controller

    startingViewController

    The currently selected view controller the transition is starting from

    destinationViewController

    The view controller that has been attempted to be selected

    transitionSuccessful

    A Boolean whether the transition to the destination view controller was successful or not. If true, the new selected view controller is destinationViewController. If false, the transition returned to the view controller it started from, so the selected view controller is still startingViewController.