【发布时间】:2016-05-23 02:51:53
【问题描述】:
当我的 TableView 中的一个单元格被选中时,我想显示一个新的 ViewController(故事板 ID:TaskDetailsVC)。这是我的 TableView 代码:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
displayTask.deselectRowAtIndexPath(indexPath, animated: true)
let row = Tasks.sharedInstance.datas[indexPath.row]
print(row)
let TaskDetailsVC = self.storyboard!.instantiateViewControllerWithIdentifier("TaskDetailsVC") as! TaskDetailsViewController
self.navigationController!.pushViewController(TaskDetailsVC, animated: true)
}
我可以在每行的右上角看到一个箭头,但是当我单击单元格时没有任何反应。我该如何解决?
我的 ViewController 代码可以在这里找到https://codeshare.io/C4uNh
【问题讨论】:
-
当你点击单元格时,这个
didSelectRowAtIndexPath函数会被调用吗?表视图的委托设置了吗? -
在
didSelectRowAtIndexPath函数中设置断点并检查它是否被调用? -
检查您当前的控制器父类/超类是否为 UINavigationController?
-
@Phuc 好像没有调用..你知道修复它吗?
-
@Pavan 我该怎么做?
标签: ios uitableview swift2