我使用自定义 UIPresentationController 来执行我自己的动画的续集。在prepareForSegue:
myDestinationController.transitioningDelegate = DBViewControllerTransitioningDelegate()
myDestinationController.modalPresentationStyle = .Custom
这是我的DBViewControllerTransitioningDelegate
:
class DBViewControllerTransitioningDelegate: NSObject, UIViewControllerTransitioningDelegate {
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
return DBOverlayPresentationController(presentedViewController: presented, presentingViewController: presenting)
}
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return DBTransitioningAnimator()
}
}
它不起作用,因为没有调用方法。但是当我设置时:
myDestinationController.transitioningDelegate = self
并在我的self
控制器中添加 2 种方法,DBViewControllerTransitioningDelegate
一切都很好。这两种方法被调用。为什么?有什么区别?