这两个API似乎获得了相同的结果。在哪种情况下,最好使用一种而不是另一种?
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let deleteAction = UITableViewRowAction(style: .destructive,
title: "Delete") { (action, indexPath) in
print("DELETE")
}
return [deleteAction]
}
Run Code Online (Sandbox Code Playgroud)
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let DeleteAction = UIContextualAction(style: .destructive, title: "Delete", handler: { (action, view, success) in
print("Delete")
})
DeleteAction.backgroundColor = .red
return UISwipeActionsConfiguration(actions: [DeleteAction])
}
Run Code Online (Sandbox Code Playgroud)