我是新手,没有在目标C中编程。所以我是新手:-)
尝试做一些相当简单的事情。链接表格 View 单元格单击以调用 Controller 中的方法,如下所示
http://prntscr.com/4m9kf7

编辑:

我在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!) {

我在所有四个中都添加了断点。
当单击单元格时,它不会在其中任何一个中停止。
请参阅屏幕截图:

http://prntscr.com/4m9ql0

最佳答案

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

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

关于ios - Swift试图将表格 View 单元格上的点击事件链接到 Controller 方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25818450/

10-12 00:04
查看更多