2016-12-01 34 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)! 
相關問題