【发布时间】:2015-11-14 16:13:41
【问题描述】:
我实现了一个 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是否存在?
prepareForSegue是否被调用过? -
嗯?我不明白@dmarsi
-
在你的
prepareForSegue函数中你把sender投到NFXRippleCellN,这正常吗? -
哦,不,这只是在此处复制和粘贴时打错了@Mindsers
-
@MikeStrong 您是否在情节提要中创建了转场?如果你在
prepareForSegue中设置一个断点,当你选择一个单元格时它会被命中吗?
标签: ios xcode swift uitableview cell