UIPercentDrivenInteractiveTransition doesn't get to animation's completion on fast gesture

前端 未结 3 1452
礼貌的吻别
礼貌的吻别 2021-02-04 19:05

I have created an interactive transition. My func animateTransition(transitionContext: UIViewControllerContextTransitioning) is quite normal, I get the container

3条回答
  •  死守一世寂寞
    2021-02-04 19:21

    I had a similar problem, but with programmatic animation triggers not triggering the animation completion block. My solution was like Sam's, except instead of dispatching after a small delay, manually call finish on the UIPercentDrivenInteractiveTransition instance.

    class SwipeInteractor: UIPercentDrivenInteractiveTransition {
      var interactionInProgress = false
      ...
    }
    
    class AnimationController: UIViewControllerAnimatedTransitioning {
      private var swipeInteractor: SwipeInteractor
      ..
      func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        ...
        if !swipeInteractor.interactionInProgress {
          swipeInteractor.finish()
        }
        ...
        UIView.animateWithDuration(...)
      }
    }
    

提交回复
热议问题