未调用 editActionsForRowAtIndexPath,目前同时提交 editingStyle 和 canEditRowAt
editActionsForRowAtIndexPath not called, both commit editingStyle and canEditRowAt present
我正在尝试向我的 table 视图行添加第二个滑动按钮,但是当我滑动一行时 editActionsForRowAtIndexPath
没有被调用。尽管我 class 声明了
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
和
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
}
我滑动时会调用这两个,因为我还有一个常规的删除按钮。
我的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]
}
我正在尝试向我的 table 视图行添加第二个滑动按钮,但是当我滑动一行时 editActionsForRowAtIndexPath
没有被调用。尽管我 class 声明了
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
和
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
}
我滑动时会调用这两个,因为我还有一个常规的删除按钮。
我的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]
}