我很难在 iPhone 的屏幕上实现抽屉滑到一半的演示。
编辑:我发现 iOS 不尊重我在 Segue 中设置的 .custom modalTransitionStyle。如果我在 中明确设置prepareForSegue:
,那么它会调用我的委托来获取UIPresentationController
.
我有一个自定义 Segue,它也是一个 UIViewControllerTransitioningDelegate。在该perform()
方法中,我将目标 transitioningDelegate 设置为 self:
self.destination.transitioningDelegate = self
我要么调用super.perform()
(如果它是 Present Modal 或 Present as Popover Segue),或者self.source.present(self.destination, animated: true)
(如果它是 Custom Segue,因为调用super.perform()
会引发异常)。
perform()
andanimationController(…)
方法被调用,但从不被调用presentationController(forPresented…)
。
最初,我尝试使用指定的自定义 Segue 类在 Storyboard “Present Modally”中制作 Segue,但这一直在删除呈现视图控制器。我尝试了“Present as Popover”,我发誓它工作过一次,因为它没有删除呈现视图控制器,但在随后的尝试中它仍然有效。
所以我把它设为“自定义”,并且perform()
仍然_UIFullscreenPresentationController
在目标视图控制器上通过预设被调用,并且我的presentationController(forPresented…)
方法永远不会被调用。
处理此问题的其他解决方案始终取决于该方法的一些错误签名。这是我的,逐字逐句:
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?
在过去的四天里,我一直在试图找出“正确的”自定义过渡,但事情似乎不像宣传的那样表现得无济于事。我错过了什么?