我试图弄清楚如何实现自定义转场,以便用户能够在本教程的帮助下向上滑动屏幕以访问下面的 Storyboard ( http://www.appcoda.com/custom-segue-animations/ )。它工作没有问题,直到需要实现倒带转场部分的部分,并且我不断收到此代码块的错误:
override func segueForUnwindingToViewController(toViewController: UIViewController, fromViewController: UIViewController, identifier: String?) -> UIStoryboardSegue {
if let id = identifier{
if id == "idFirstSegueUnwind" {
let unwindSegue = FirstCustomSegueUnwind(identifier: id, source: fromViewController, destination: toViewController, performHandler: { () -> Void in
})
return unwindSegue
}
}
return super.segueForUnwindingToViewController(toViewController, fromViewController: fromViewController, identifier: identifier)
}
特别是这一行:
return super.segueForUnwindingToViewController(toViewController, fromViewController: fromViewController, identifier: identifier)
它给出这样的错误:可选类型“UIStoryboardSegue”的值?未拆封;你的意思是使用“!”吗?或“?”?
我尝试用这行代码替换它,认为参数可能有问题:
return super.segueForUnwindingToViewController(toViewController: UIViewController, fromViewController: UIViewController, identifier: String?)
但是这次我收到调用中参数“fromViewController”缺少参数错误。
有人对如何解决这个问题有任何建议吗?
最佳答案
您必须使用“!”解开可选类型 UIStoryboardSegue :
return super.segueForUnwindingToViewController(toViewController, fromViewController: fromViewController, identifier: identifier)!
关于ios - 在第二个 View Controller 上展开 Segue 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40914368/