简体   繁体   English

是否有任何委托方法在TableView单元格编辑中启用带有删除功能的“编辑”按钮

[英]Is there any Delegate method to enable Edit Button With Delete In TableView Cell Editing

I'm Working On a project in which i have to show Edit option like Delete in Table View Editing Style like in given picture. 我正在研究一个项目,在该项目中,我必须在给定图片中以表视图编辑样式显示“删除”之类的“编辑”选项。

在此处输入图片说明

Is there any delegate method to Show Edit Option in TableView Cell Editing 是否有任何委托方法在TableView单元格编辑中显示编辑选项

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM