gpt4 book ai didi

ios - 如何在 UIStoryboardSegue 中实现 UIViewControllerTransitioningDelegate?

转载 作者:行者123 更新时间:2023-11-28 16:19:31 28 4
gpt4 key购买 nike

这就是我现在做的:

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: 从 Storyboard 中获取 Controller 。 Controller 以正确的方式呈现:

enter image description here

但我需要通过自定义 segue 实现相同的结果:

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)
}
}

但它不起作用。为什么?

最佳答案

perform 结束时,您需要调用 presentViewController(destinationViewController, animated: true, completion: nil)

关于ios - 如何在 UIStoryboardSegue 中实现 UIViewControllerTransitioningDelegate?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38631422/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com