title: Interactive UIViewController Transition with new "usingSpringWithDamping:initialSpringVelocity"-animation
body: <p>I try to implement a interactive custom modal UIViewController transition using the new iOS7 APIs. Everything is working as desired as long as I don't use the new </p>
  
  <pre><code> + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
  </code></pre>
  
  <p>method for animating the transition. It is working fine if I invoke the transition via a button. The problem occurs when the transition is interactive, driven by a GestureRecognzier. If I release my finger the animation is immediately cut of and won't finish. The same code is working if I use </p>
  
  <pre><code>animateWithDuration:delay:options:animations:completion:
  </code></pre>
  
  <p>instead.</p>
  
  <p>Here is the code which animates the transition:</p>
  
  <pre><code>- (void)animateTransition:(id &lt;UIViewControllerContextTransitioning&gt;)transitionContext {
     UIViewController *fromViewController = [transitionContext  viewControllerForKey:UITransitionContextFromViewControllerKey];
     UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
     CGRect fullFrame = transitionContext.containerView.frame;
  
  if (!self.dismissal) {
      [transitionContext.containerView addSubview:fromViewController.view];
      [transitionContext.containerView addSubview:toViewController.view];
      fromViewController.view.frame = fullFrame;
      toViewController.view.frame = CGRectMake(0, fullFrame.size.height, 0, 0);
  
      [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:UIViewAnimationOptionTransitionNone animations:^{
          //animation
          toViewController.view.frame = CGRectMake(0,0, fullFrame.size.width, fullFrame.size.height);
      } completion:^(BOOL finished) {
          [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
      }];
  
  } else {
      [transitionContext.containerView addSubview:toViewController.view];
      [transitionContext.containerView addSubview:fromViewController.view];
      fromViewController.view.frame = fullFrame;
  
      [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 usingSpringWithDamping:.5 initialSpringVelocity:.5 options:0 animations:^{
          fromViewController.view.frame = CGRectMake(0, fullFrame.size.height, fullFrame.size.width, fullFrame.size.height);
      } completion:^(BOOL finished) {
          [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
      }];
  
  //This is working fine
  //        [UIView animateWithDuration:[self transitionDuration:transitionContext]/2       animations:^{
  //            fromViewController.view.frame = CGRectMake(0, fullFrame.size.height, fullFrame.size.width, fullFrame.size.height);
  //        } completion:^(BOOL finished) {
  //            [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
  //        }];
  }
  </code></pre>
  
  <p>This is the code behind the gesture recogniser:</p>
  
  <pre><code>#pragma mark - Gesture recognition
  - (void)handlePan:(UIScreenEdgePanGestureRecognizer *)pgr
  {
  
  CGPoint translation = [pgr translationInView:pgr.view];
  CGFloat percentage  = fabs(translation.x / CGRectGetWidth(pgr.view.frame));
  
  switch (pgr.state) {
      case UIGestureRecognizerStateBegan:
          self.interactionInProgress = YES;
          [self.respondingVC proceedToNextViewController];
          break;
  
      case UIGestureRecognizerStateChanged: {
          [self updateInteractiveTransition:percentage];
          break;
      }
  
      case UIGestureRecognizerStateEnded:
          if(percentage &lt; 0.5) {
              [self cancelInteractiveTransition];
          } else {
              [self finishInteractiveTransition];
          }
          self.interactionInProgress = NO;
          break;
  
      case UIGestureRecognizerStateCancelled:
          [self cancelInteractiveTransition];
          self.interactionInProgress = NO;
  
      default:
          break;
  }
  }
  </code></pre>