UITableView itself with the (add, delete) editing function:
1. As long as the edit code that calls UITableView goes into edit state:
[Self.tableview setediting:!self.tableview.editing Animated:yes];
2. The UITableView that enters the edit state will invoke the proxy's
-(uitableviewcelleditingstyle) TableView: (uitableview *) TableView Editingstyleforrowatindexpath: To determine whether to increase or remove the method.
Uitableviewcelleditingstyle is an enumeration value, such as Uitableviewcelleditingstyledelete,uitableviewcelleditingstyleinsert
The overall code is as follows:
#pragma Mark Click Edit Delete-(ibaction) Trashclick: (ID) sender {self.tableview.tag=edit_move; [Self.tableview setediting:!self.tableview.editing animated:yes];} #pragma mark-tableviewdatasource#pragma mark the method that is called when the delete State is clicked when the edit state is present #pragma mark when adding a button to increase the status of a click on the option to save the call Method-(void) TableView: (UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath :(Nsindexpath *) indexpath{if (tableview.tag==20) {[Self.arr removeObjectAtIndex:indexPath.row]; [TableView Deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationleft]; } else {[Self.arr insertobject:@ "New row ..." atindex:indexpath.row+1]; Nsindexpath *indexnew=[nsindexpath indexpathforrow:indexpath.row+1 insection:0]; [TableView insertrowsatindexpaths:@[indexnew] withrowanimation:uitableviewrowanimationright]; }} #pragma mark clicks on edit to delete or Add button-(Uitableviewcelleditingstyle) TableView: (UITableView *) TableView EditingstyleforrOwatindexpath: (Nsindexpath *) indexpath{if (tableview.tag==20) {return uitableviewcelleditingstyledelete; } else {return uitableviewcelleditingstyleinsert; }} #pragma mark moves the item so that it can save the editing order after editing the mode-(void) TableView: (UITableView *) TableView Moverowatindexpath: (Nsindexpath *) Sourceindexpath Toindexpath: (Nsindexpath *) destinationindexpath{nsstring *currstr=self.arr[sourceindexpath.row]; [Self.arr RemoveObjectAtIndex:sourceIndexPath.row]; [Self.arr insertobject:currstr AtIndex:destinationIndexPath.row]; [TableView Reloaddata];} #pragma mark Click Edit Add-(ibaction) AddClick: (ID) sender {self.tableview.tag=edit_add; [Self.tableview setediting:!self.tableview.editing animated:yes];}