未为容器视图控制器调用的UIViewControllerTransitioningDelegate函数

时间:2018-11-30 23:41:16

标签: uiviewcontroller uikit transition

我正在以编程方式将View Controller的视图添加到容器视图,并希望它具有动画过渡,但是即使我调用了UIViewControllerTransitioningDelegate,也没有调用beginAppearanceTransition(animated:)函数。

let secondViewController = SecondViewController()
self.secondViewController = secondViewController
secondViewController.view.translatesAutoresizingMaskIntoConstraints = false
containerView.addSubview(secondViewController.view)
containerView.addConstraints(secondViewController.view.pinnedConstraints(view: containerView))
secondViewController.transitioningDelegate = self
secondViewController.modalPresentationStyle = .overCurrentContext
secondViewController.didMove(toParent: self)
secondViewController.beginAppearanceTransition(true, animated: true)

执行上述代码时,当前视图控制器中永远不会调用animationController(forPresented:presenting:source:) -> UIViewControllerAnimatedTransitioning?

0 个答案:

没有答案