0
這就是我現在做的事:如何在UIStoryboardSegue中實現UIViewControllerTransitioningDelegate?
func presentOverlayController(controller: UIViewController) {
controller.modalPresentationStyle = .Custom
controller.transitioningDelegate = self
presentViewController(controller, animated: true, completion: nil)
}
//MARK: - UIViewControllerTransitioningDelegate
public func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
return OverlayPresentationController(presentedViewController: presented, presentingViewController: presenting)
}
它工作得真棒。首先,我使用.instantiateViewControllerWithIdentifier:
從故事板獲取控制器。控制器給出的正確方法:
但同樣的結果,我需要實現我的自定義賽格瑞:
class OverlaySegue: UIStoryboardSegue, UIViewControllerTransitioningDelegate {
override func perform() {
destinationViewController.modalPresentationStyle = .Custom
destinationViewController.transitioningDelegate = self
}
//MARK: - UIViewControllerTransitioningDelegate
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
return OverlayPresentationController(presentedViewController: presented, presentingViewController: presenting)
}
}
,但它不工作。爲什麼?
當然,我怎麼能忘記這個? –