我正在尝试升级项目代码,并发现此警告
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let deleteRowAction = UITableViewRowAction(style: .destructive, title: deleteActionTitle) { [unowned self] (_, indexPath) in
//code you want to execute }
return [deleteRowAction]
}
答案 0 :(得分:0)
您可以在UISwipeActionsConfiguration
上使用UITableViewRowAction
,例如
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
return UISwipeActionsConfiguration()
}
答案 1 :(得分:0)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let contextItem = UIContextualAction(style: .destructive, title: deleteActionTitle) { (contextualAction, view, boolValue) in
//Code I want to do here
}
let swipeActions = UISwipeActionsConfiguration(actions: [contextItem])
return swipeActions
}