iOS Developer Library

Developer

UIKit Framework Reference UIViewControllerInteractiveTransitioning Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIViewControllerInteractiveTransitioning

Inheritance


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 7.0 and later.

To enable an object (such as a navigation controller) to drive a view controller transition, configure a custom class to adopt the UIViewControllerInteractiveTransitioning protocol. An object that supports this protocol is called an interactive transition delegate.

An interactive transition delegate can respond to touch events, or to time-varying programmatic input, by speeding up, slowing down, or even reversing the progress of a view controller transition. For example, an interactive transition on a navigation controller could respond to a swipe gesture by moving a view controller onto or off of the navigation stack.

To support an interactive view controller transition, you must also provide a transition animator delegate, which is a custom object that adopts the UIViewControllerAnimatedTransitioning protocol. The transition delegate and the transition animator can, if you wish, be defined within a single custom class, but the class must adopt both protocols.

If you instead want to provide a fixed-duration animated view controller transition—one that does not support user interaction—use a transition animator delegate on its own. Refer to UIViewControllerAnimatedTransitioning Protocol Reference.

For the methods you can call to retrieve view transition context information from within your startInteractiveTransition: method, refer to UIViewControllerContextTransitioning Protocol Reference.

  • Called when the system needs to set up the interactive portions of a view controller transition and start the animations. (required)

    Declaration

    Swift

    func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning)

    Objective-C

    - (void)startInteractiveTransition:(id<UIViewControllerContextTransitioning>)transitionContext

    Parameters

    transitionContext

    The context object containing information about the transition.

    Discussion

    Your implementation of this method should use the data in the transitionContext parameter to configure user interactivity for the transition and then start the animations. While tracking user interactions, your event handling code should regularly call the context object’s updateInteractiveTransition: method to report on how much of the transition is now complete. If events indicate that the user has canceled the transition, call the cancelInteractiveTransition method. If events indicate that the transition has finished, call the finishInteractiveTransition method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Called when the system needs the animation completion curve for an interactive view controller transition.

    Declaration

    Swift

    optional func completionCurve() -> UIViewAnimationCurve

    Objective-C

    - (UIViewAnimationCurve)completionCurve

    Return Value

    Default value is UIViewAnimationCurveEaseInOut, with other possible values described in the UIViewAnimationCurve type definition.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Called when the system needs the speed at which to complete an interactive transition, after the interactive portion is finished.

    Declaration

    Swift

    optional func completionSpeed() -> CGFloat

    Objective-C

    - (CGFloat)completionSpeed

    Return Value

    Default value is 1.0, which corresponds to the total (noninteractive) transition duration scaled by the percentage of the transition remaining. Value must be greater than 0.0.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.