[英]Is there any Delegate method to enable Edit Button With Delete In TableView Cell Editing
You can use editActionsForRowAt
delegate method. 您可以使用
editActionsForRowAt
委托方法。 Check this link 检查此链接
Asks the delegate for the actions to display in response to a swipe in the specified row.
要求代表响应于指定行中的滑动而显示的动作。
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let editAction = UITableViewRowAction(style: .normal, title: "Edit") { (rowAction, indexPath) in
//TODO: edit the row at indexPath here
}
editAction.backgroundColor = .gray
let deleteAction = UITableViewRowAction(style: .normal, title: "Delete") { (rowAction, indexPath) in
//TODO: Delete the row at indexPath here
}
deleteAction.backgroundColor = .red
return [deleteAction,editAction]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.