【发布时间】:2015-06-29 07:08:07
【问题描述】:
我使用自定义 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 控制器中添加我的DBViewControllerTransitioningDelegate 中的2 个方法,一切都很好。这两种方法被调用。为什么?有什么区别?
【问题讨论】:
-
您可能需要事先实例化您的动画师。就像在您的委托类的
init()中一样
标签: swift delegates uipresentationcontroller