Interface UIViewControllerContextTransitioning


  • public interface UIViewControllerContextTransitioning
    A transition context object is constructed by the system and passed to the animator in its animateTransition: and transitionDuration: methods as well as to the interaction controller in its startInteractiveTransition: method. If there is an interaction controller its startInteractiveTransition: is called first and its up to the the interaction controller object to call the animateTransition: method if needed. If there is no interaction controller, then the system automatically invokes the animator's animateTransition: method. The system queries the view controller's transitioningDelegate or the navigation controller's delegate to determine if an animator or interaction controller should be used in a transition. The transitioningDelegate is a new propery on UIViewController and conforms to the UIViewControllerTransitioningDelegate protocol defined below. The navigation controller likewise has been augmented with a couple of new delegate methods. The UIViewControllerContextTransitioning protocol can be adopted by custom container controllers. It is purposely general to cover more complex transitions than the system currently supports. For now, navigation push/pops and UIViewController present/dismiss transitions can be customized. Information about the transition is obtained by using the viewControllerForKey:, initialFrameForViewController:, and finalFrameForViewController: methods. The system provides two keys for identifying the from view controller and the to view controller for navigation push/pop and view controller present/dismiss transitions. All custom animations must invoke the context's completeTransition: method when the transition completes. Furthermore the animation should take place within the containerView specified by the context. For interactive transitions the context's updateInteractiveTransition:, finishInteractiveTransition or cancelInteractiveTransition should be called as the interactive animation proceeds. The UIPercentDrivenInteractiveTransition class provides an implementation of the UIViewControllerInteractiveTransitioning protocol that can be used to interactively drive any UIView property animations that are created by an animator.
    • Method Detail

      • cancelInteractiveTransition

        void cancelInteractiveTransition()
      • completeTransition

        void completeTransition​(boolean didComplete)
        This must be called whenever a transition completes (or is cancelled.) Typically this is called by the object conforming to the UIViewControllerAnimatedTransitioning protocol that was vended by the transitioning delegate. For purely interactive transitions it should be called by the interaction controller. This method effectively updates internal view controller state at the end of the transition.
      • containerView

        UIView containerView()
        The view in which the animated transition should take place.
      • finishInteractiveTransition

        void finishInteractiveTransition()
      • initialFrameForViewController

        CGRect initialFrameForViewController​(UIViewController vc)
        The frame's are set to CGRectZero when they are not known or otherwise undefined. For example the finalFrame of the fromViewController will be CGRectZero if and only if the fromView will be removed from the window at the end of the transition. On the other hand, if the finalFrame is not CGRectZero then it must be respected at the end of the transition.
      • isAnimated

        boolean isAnimated()
        Most of the time this is YES. For custom transitions that use the new UIModalPresentationCustom presentation type we will invoke the animateTransition: even though the transition should not be animated. This allows the custom transition to add or remove subviews to the container view.
      • isInteractive

        boolean isInteractive()
        This indicates whether the transition is currently interactive.
      • pauseInteractiveTransition

        void pauseInteractiveTransition()
        This should be called if the transition animation is interruptible and it is being paused.
      • presentationStyle

        long presentationStyle()
      • transitionWasCancelled

        boolean transitionWasCancelled()
      • updateInteractiveTransition

        void updateInteractiveTransition​(double percentComplete)
        An interaction controller that conforms to the UIViewControllerInteractiveTransitioning protocol (which is vended by a container view controller's delegate or, in the case of a presentation, the transitioningDelegate) should call these methods as the interactive transition is scrubbed and then either cancelled or completed. Note that if the animator is interruptible, then calling finishInteractiveTransition: and cancelInteractiveTransition: are indications that if the transition is not interrupted again it will finish naturally or be cancelled.
      • viewControllerForKey

        UIViewController viewControllerForKey​(java.lang.String key)
        Currently only two keys are defined by the system - UITransitionContextToViewControllerKey, and UITransitionContextFromViewControllerKey. Animators should not directly manipulate a view controller's views and should use viewForKey: to get views instead.
      • viewForKey

        UIView viewForKey​(java.lang.String key)
        Currently only two keys are defined by the system - UITransitionContextFromViewKey, and UITransitionContextToViewKey viewForKey: may return nil which would indicate that the animator should not manipulate the associated view controller's view.