在我的应用程序中,我有几个用于自定义转换的类。在 Swift 3 之前,一切都运行良好。但是,在更新到 Swift 3 之后,func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController)
总是显示为 nil。它应该返回启动转换的 UIViewController。一切都与以前的 Swift 版本完美配合。我错过了什么吗?
1 回答
2
我被这个问题困扰了一个多小时,在 swift 3.0 中,函数签名约定发生了变化,所以这可能是导致问题的原因,因为这个变化最终解决了这个问题。由于协议方法是可选的,因此它们不会被调用并且没有给出错误。
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return ...
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return...
}
于 2016-10-20T03:48:22.637 回答