UIViewControllerTransitionCoordinator Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 7.0 and later.
Declared in
UIViewControllerTransitionCoordinator.h

Overview

During an active view controller transition, use a view controller transition coordinator to respond to user cancelation of the transition.

After transition starts, obtain a view controller transition coordinator by calling [UIViewController transitionCoordinator].Use it to register blocks containing code you want to run at various points during the transition. The system releases the coordinator after the transition completes and the final callback is made.

You can employ a view controller transition coordinator to do either or both of the following:

Tasks

Responding to View Controller Transition Progress

Instance Methods

animateAlongsideTransition:completion:

Called when the coordinator needs to know the custom animation or completion block for a view controller transition; for animations specified to run within the container view. (required)

- (BOOL)animateAlongsideTransition:(void (^)(id<UIViewControllerTransitionCoordinatorContext> context))animation completion:(void (^)(id<UIViewControllerTransitionCoordinatorContext> context))completion
Parameters
animation

The animation you want to run during the transition. The animation runs in the same animation context as the transition itself.

The animation you specify must take place in a view descended from the container view.

If you implement a transitioning animator that employs Core Animation directly, rather than using UIView animations, the animation you specify runs after the animateTransition: method returns.

To use this method to specify only a completion block object, set this parameter to nil.

completion

The block of code to execute after the transition finishes.

The system might invoke the completion block before your animation finishes.

Return Value

YES if the specified animation is successfully queued to run; otherwise NO.

Discussion

Use this method to specify an animation to run concurrently with the view controller transition animation, and to specify a block of code to run upon completion of the transition. Both aspects are optional:

  • You can specify an animation and no completion block

  • You can specify a completion block and no animation

To specify an animation that takes place in a view not descended from the container view, instead use the animateAlongsideTransitionInView:animation:completion: method.

If you specify a completion block and an animation, and the animation fails to queue, the completion block can run even though the method returns NO.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIViewControllerTransitionCoordinator.h

animateAlongsideTransitionInView:animation:completion:

Called when the coordinator needs to know the custom animation or completion block for a view controller transition; for animations specified to run outside the container view. (required)

- (BOOL)animateAlongsideTransitionInView:(UIView *)view animation:(void (^)(id<UIViewControllerTransitionCoordinatorContext> context))animation completion:(void (^)(id<UIViewControllerTransitionCoordinatorContext> context))completion
Parameters
view

The view in which you want the specified animation to take place, or a view from which the animated view descends.

animation

The animation you want to run during the transition. The animation runs in the same animation context as the transition itself.

If you implement a transitioning animator that employs Core Animation directly, rather than using UIView animations, the animation you specify runs after the animateTransition: method returns.

To use this method to specify only a completion block object, set this parameter to nil.

completion

The block of code to execute after the transition finishes.

The system might invoke the completion block before your animation finishes.

Return Value

YES if the specified animation is successfully queued to run; otherwise NO.

Discussion

Use this method to specify an animation to run concurrently with the view controller transition animation, and to specify a block of code to run upon completion of the transition. Both aspects are optional:

  • You can specify an animation and no completion block

  • You can specify a completion block and no animation

The animation you specify in the animation parameter must take place in a view descended from view you specify in the view parameter.

To specify an animation that takes place in a view descended from the container view, instead use the animateAlongsideTransition:completion: method.

If you specify a completion block and an animation, and the animation fails to queue, the completion block can run even though the method returns NO.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIViewControllerTransitionCoordinator.h

notifyWhenInteractionEndsUsingBlock:

Called when interaction ends during an interactive view controller transition. (required)

- (void)notifyWhenInteractionEndsUsingBlock:(void (^)(id<UIViewControllerTransitionCoordinatorContext> context))handler
Parameters
handler

Code to conditionally respond to user cancelation of an interactive view controller transition.

When a user cancels an interactive transition, the system first calls this method. It then calls the viewWillDisappear: method on the view controller that was appearing prior to cancelation, and calls the viewWillAppear: method on the view controller that was disappearing.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIViewControllerTransitionCoordinator.h