Swift 未调用EditActionsErrorWatIndeXPath,commit editingStyle和CaneditRow当前都未调用

Swift 未调用EditActionsErrorWatIndeXPath,commit editingStyle和CaneditRow当前都未调用,swift,tableview,ios10,tableviewcell,Swift,Tableview,Ios10,Tableviewcell,我正在尝试向表视图行添加第二个滑动按钮,但滑动行时未调用editactionsforrowatinedxpath。这是尽管我的类声明两者 override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return true } 及 当我刷卡时会调用这两个按钮,因为我还有一个常规的删除按钮 我的editActionsForRowAtIndexPath函数

我正在尝试向表视图行添加第二个滑动按钮,但滑动行时未调用
editactionsforrowatinedxpath
。这是尽管我的类声明两者

override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {

    return true
}

当我刷卡时会调用这两个按钮,因为我还有一个常规的删除按钮

我的
editActionsForRowAtIndexPath
函数编写如下:

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewRowAction? {

    print("triggered!")

    let more = UITableViewRowAction(style: .default, title: "More") { action, index in
        print("more button tapped")
    }
    more.backgroundColor = UIColor.blue

    return more
}

提前谢谢

对于此特定方法,您没有使用更新的Swift 3 API。委托方法应写成:

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    print("triggered!")

    let more = UITableViewRowAction(style: .default, title: "More") { action, index in
        print("more button tapped")
    }
    more.backgroundColor = UIColor.blue

    return [more]
}

您的
tableView
delegate
属性设置了吗?我也遇到了同样的问题,@Aaron的回答对我很有用。我意外地从类中删除了tableView的委托。如果其他任何人由于其他原因遇到此问题,请注意,此委托调用是在用户实际滑动tableView行时进行的,而不是在调用tableView重载数据时进行的。请确保没有任何内容覆盖tableView,以防止发生刷卡。您已经澄清了我的错误:您的代码不起作用,但很接近:我的返回值中缺少括号,[更多]。想解释一下为什么两个选项中没有括号不起作用吗?@rodrigochousal
more
是一个动作,而[more]是一个动作数组。
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    print("triggered!")

    let more = UITableViewRowAction(style: .default, title: "More") { action, index in
        print("more button tapped")
    }
    more.backgroundColor = UIColor.blue

    return [more]
}