Ios Swift尝试将表视图单元格上的tap事件链接到控制器方法

Ios Swift尝试将表视图单元格上的tap事件链接到控制器方法,ios,xcode,swift,Ios,Xcode,Swift,我是swift新手,没有在目标C中编程。所以我是新手:- 尝试做一些相当简单的事情。链接一个表视图单元格单击以调用控制器中的方法,如下所示 编辑: 我的MasterController中有这些方法 override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { override func tableView(tableView: UITableView, cell

我是swift新手,没有在目标C中编程。所以我是新手:- 尝试做一些相当简单的事情。链接一个表视图单元格单击以调用控制器中的方法,如下所示

编辑:

我的MasterController中有这些方法

  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
  override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
 override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
我在所有4个中都添加了断点。 当点击单元格时,它不会在任何一个单元格中停止。 请参见屏幕截图:


您需要实现didSelectRowAtIndexPath委托方法,并将处理代码放入其中

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
     //CODE TO BE RUN ON CELL TOUCH
}
对于Swift 4:

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print("row selected: \(indexPath.row)")
}

在屏幕截图中,尝试通过连接助手连接该方法。您需要实现DidSelectRowatinex路径委托方法,并将处理代码放入该方法中。您好@Woodstock,感谢您的快速响应。它仍然不起作用,我已经编辑了question@WebQube我认为您必须更改方法的签名才能删除“!”最新Xcode beta版中的符号-请使用我最新的swift3答案它的override func tableView_uTableView:UITableView,didSelectRowAt indexPath:indexPath{