Swift3 Segue转换后从未调用transitioningDelegate

Swift3 Segue转换后从未调用transitioningDelegate,swift3,xcode8,Swift3,Xcode8,因此,我尝试在我的应用程序从一个视图控制器过渡到另一个视图控制器时实现自定义动画,但由于某些原因,我的自定义动画类中的animateTransition函数从未被调用 为了记录在案,我使用的是Xcode 8,并使用Swift 3编写。我试图克服的问题是,函数从未被调用——我将在将来整理实际的动画,现在是它的 这是我的CustomPresentAnimationController类中的代码,它应该处理转换动画 import UIKit class CustomPresentAnimationC

因此,我尝试在我的应用程序从一个视图控制器过渡到另一个视图控制器时实现自定义动画,但由于某些原因,我的自定义动画类中的animateTransition函数从未被调用

为了记录在案,我使用的是Xcode 8,并使用Swift 3编写。我试图克服的问题是,函数从未被调用——我将在将来整理实际的动画,现在是它的

这是我的CustomPresentAnimationController类中的代码,它应该处理转换动画

import UIKit

class CustomPresentAnimationController: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate, UINavigationControllerDelegate {

    let duration = 0.5

    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        print("Checking duration")
        return duration
    }

    func animationController(forPresented presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        print("This ran 1")
        return self
    }

    func presentationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        print("This ran 2")
        return self
    }

    func animationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        print("This ran 3")
        return self
    }

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {

        print("It's working!")

        guard let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from) else {
            return
        }

        guard let toView = transitionContext.view(forKey: UITransitionContextViewKey.to) else {
            return
        }

        let container = transitionContext.containerView

        let screenOffDown = CGAffineTransform(translationX: 0, y: -container.frame.height)

        let screenOffUp = CGAffineTransform(translationX: 0, y: container.frame.height)

        container.addSubview(fromView)
        container.addSubview(toView)

        toView.transform = screenOffUp

        UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.8, options: [], animations: {

            fromView.transform = screenOffDown
            fromView.alpha = 0.5
            toView.transform = CGAffineTransform.identity
            toView.alpha = 1

        }) { (success) in
            transitionContext.completeTransition(success)
        }

    }

}
以下是我的ViewController的代码(我的两个视图控制器都引用了该代码)

当我运行代码并单击我提供的按钮时,该按钮链接到我的seance视图控制器,并设置为“显示模式”,视图会随着标准转换(从底部向上滑动)而更改,并且以下内容会打印到Xcode:

Transitioing Delegate set to nil
doing our custom transition
<moduleView.ViewController: 0x7fe427f09a40>
Should do something...
Optional(<moduleView.CustomPresentAnimationController: 0x60800002e980>)
transitioning委托设置为nil
做我们的自定义转换
我应该做点什么。。。
可选()
很明显,第一行与第一个视图加载时一样,其余的都显示我的TransitionLegate设置在Segue目标上,并且确实在第二个视图加载时加载,并且TransitionLegate设置为CustomPresentAnimationController。。。然而,该类中没有任何函数被调用,因为它从不从这些函数中输出任何内容


感谢您的帮助

确保实现委托的方法签名与更新的Swift 3语法匹配

Transitioing Delegate set to nil
doing our custom transition
<moduleView.ViewController: 0x7fe427f09a40>
Should do something...
Optional(<moduleView.CustomPresentAnimationController: 0x60800002e980>)