簡體   English   中英

如何修復UITableViewCell segue

[英]How to fix UITableViewCell segue

我實現了一個NFXRipple單元格,但是現在這些單元格不會切換到下一個表格視圖。 這是我的cellForRowAtIndexPath

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!]
    }

我該怎么調整? 還是我缺少什么?

更新:這是我的控制器中的代碼:

   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!]
    }

您是否嘗試以編程方式致電segue? 也許解決方案只是使用tableView(_: UITableView, didSelectRowAtIndexPath: NSIndexPath)來調用您的segue。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM