-2
我以前使用下面的代码来实现删除了细胞在我UITableView
:冲突的UITableView编辑功能
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
feedTable.deleteRows(at: [indexPath!], with: .fade)
}
}
不过,现在我想添加自定义操作,所以我把这个添加的细胞:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let edit = UITableViewRowAction(style: .normal, title: "Edit", handler: { (action, indexPath) in
})
let delete = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexPath) in
}
edit.backgroundColor = UIColor.green
return [delete, edit]
}
现在我很困惑我是否需要连原commit editingStyle
功能。我是否应该将所有编辑处理代码(feedTable.deleteRows(at: [indexPath!], with: .fade)
)移至新功能?
在我看来,有很多不同的功能与UITableViewCell
编辑有关,我很困惑要使用哪些功能。