I got lost in the universe of transitions. I want an interactive transition using push segue. The following code works with a modal segment, but not with a single click:
(Using the push segment, the animation is not interactive and is canceled)
FirstViewController.swift
let transitionManager = TransitionManager() override func viewDidLoad() { super.viewDidLoad() transitionManager.sourceViewController = self
TransitionManager.swift
class TransitionManager: UIPercentDrivenInteractiveTransition,UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate,UIViewControllerInteractiveTransitioning { var interactive = false var presenting = false var panGesture : UIPanGestureRecognizer! var destViewController : UIViewController! var sourceViewController : UIViewController! { didSet { panGesture = UIPanGestureRecognizer(target: self, action: "gestureHandler:") sourceViewController.view.addGestureRecognizer(panGesture) } } func gestureHandler(pan : UIPanGestureRecognizer) { let translation = pan.translationInView(pan.view!) let velocity = pan.velocityInView(pan.view!) let d = translation.x / pan.view!.bounds.width * 0.5 switch pan.state { case UIGestureRecognizerState.Began : interactive = true sourceViewController.performSegueWithIdentifier("1to2", sender: self) case UIGestureRecognizerState.Changed : self.updateInteractiveTransition(d) default : interactive = false if d > 0.2 || velocity.x > 0 { self.finishInteractiveTransition() } else { self.cancelInteractiveTransition() } } } func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
}
Storyboard
Segu from FirstViewController to SecondViewController.
ID: "1to2"
Segue: click
Appointment: current
thanks for your help
source share