2016-01-12 30 views
0

我在準備Segue公司一個問題,當我嘗試小區標題添加到導航項目這個問題似乎不能使用覆蓋FUNC prepareForSegue(>>細胞標題導航項目<<)

image description here

func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? { 
    self.performSegueWithIdentifier("indeaa", sender: tableView) 
    return indexPath 
} 


    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){ 
    if segue.identifier == "indeaa" 
    { 
     let vc = segue.destinationViewController as UIViewController 
     let indexpath:NSIndexPath = tableaa.indexPathForSelectedRow! 
       vc.title = arr[indexpath.row] 
    } 
    } 
} 

回答

0

應用程序崩潰的原因是可選變量未正確解包。 您可以使用可選的綁定或鏈接方法打開可選項。

替換 -

let indexpath:NSIndexPath = tableaa.indexPathForSelectedRow! 

if let indexpath = tableaa.indexPathForSelectedRow! {vc.title = arr[indexpath.row]} 
+0

的問題是解決了,但出現了另一個問題 –

+0

當我在小區1上單擊顯示第一導航欄是空的,當我返回並點擊花葯(細胞) 我顯示細胞1的名稱,當我點擊任何細胞時,我顯示的名稱爲 (花葯(細胞)) –

相關問題