2015-08-20 38 views
1

我實現了一個NFXRipple單元,但現在單元格不會延續到下一個表格視圖。這裏是我的cellForRowAtIndexPath如何修復UITableViewCell segue

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     let cell: NFXRippleCell = NFXRippleCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell") 
     cell.textLabel?.text = aSport[indexPath.row].name 
     cell.backgroundColor = UIColor.whiteColor() 
     cell.textLabel?.font = UIFont(name: "HelveticaNeue", size: 16) 
     cell.textLabel?.textColor = UIColor.blackColor() 

     return cell 
} 

和我prepareForSegue

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 
     let cell = sender as! NFXRippleCellN 
     let row = tableView.indexPathForCell(cell)?.row 
     let detail = segue.destinationViewController as! SecondTableViewController 
     detail.selectedSport = aSport[row!] 
    } 

我應該怎麼調整?或者有什麼我失蹤?

UPDATE:這是何典在我的控制器:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     let cell: NFXRippleCell = NFXRippleCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell") 
     cell.textLabel?.text = aSportl[indexPath.row].name 
     cell.textLabel?.text = aSport[indexPath.row].name 
     cell.backgroundColor = UIColor.clearColor() 
     cell.textLabel?.font = UIFont(name: "HelveticaNeue-Thin", size: 16) 
     cell.textLabel?.textColor = UIColor.whiteColor() 

     return cell 
    } 

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { performSegueWithIdentifier("firstSports", sender: self.tableView(tableView, cellForRowAtIndexPath: indexPath)) } 


    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 
     let cell = sender as! NFXRippleCell 
     let row = tableView.indexPathForCell(cell)?.row 
     let detail = segue.destinationViewController as! SecondTableViewController 
     detail.selectedSchool = aSport[row!] 
    } 
+0

這可能是一個愚蠢的問題,但segue存在嗎? 'prepareForSegue'是否被稱爲? – dmarsi

+0

呵呵?我不明白@dmarsi –

+0

在''prepareForSegue'函數中,您在'NFXRippleCellN'中投送了發件人,這是否正常? – Mindsers

回答

0

你嘗試調用Segue公司編程?也許解決方案只是使用tableView(_: UITableView, didSelectRowAtIndexPath: NSIndexPath)來調用你的segue。

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) 
{ 
    performSegueWithIdentifier("first", sender: self.tableView(tableView, cellForRowAtIndexPath: indexPath)) 
} 
+0

在該方法中應該使用哪些代碼來準備segue? –

+0

不*準備*但*執行*。試試'performSegueWithIdentifier()'。這個方法將調用segue和你的'prepareforSegue'方法 – Mindsers

+0

沒有那麼做 –