2016-12-01 66 views
0

我试图弄清楚如何实现一个自定义的segue,以便用户能够在本教程(http://www.appcoda.com/custom-segue-animations/)的帮助下向上轻扫屏幕以访问故事板。它的工作没有问题,直到部分,其中复卷SEGUE部分需要落实,我一直得到错误与下面的代码块:在第二个视图控制器上展开Segue错误

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” 。

任何人有任何建议如何解决这个问题?

+0

对于您的错误信息,也许它的工作原理:(刚加入该行的结束!) 回报super.segueForUnwindingToViewController(toViewController,fromViewController:fromViewController,标识:标识)! –

+0

当我这样做时,它会生成,但当我尝试向上滑动以触发休息时会出现错误。它引导我到AppDelegate页面并突出显示**类AppDelegate:UIResponder,UIApplicationDelegate {**部分然后给出错误**线程1:信号SIGABRT ** – Deniz

回答

0

你必须打开可选的类型UIStoryboardSegue与“!” :

return super.segueForUnwindingToViewController(toViewController, fromViewController: fromViewController, identifier: identifier)! 
相关问题