1.UITableView supplement 1??:-( void) P_data@property (nonatomic,retain) Nsmutablearray *dataarray; @property (nonatomic,assign) Uitableviewcelleditingstyle editstyle;-(void) p_data{ Nsmutablearray *arr1 = @[@ "Fan Bingbing", @ "ShK", @ "Zhou Xun" ].mutablecopy; Nsmutablearray *arr2 = @[@ "Bangbangbang", @ "Boomshakalaka", @ "Comeonboys", @ " Comeongirls "].mutablecopy; Self.dataarray = [Nsmutablearray array]; [ Self.dataarray addobject:arr1]; [Self.dataarray addobject:arr2];} 2??:number-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{ return Self.dataArray.count;} 3??:row-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (Nsinteger) section{ return [self.dataarray[section] count];} Cell.textLabel.text = Self.dataarray[indexpath.section][indexpath.row];2.uitableview modified 1??: let TableView in edit state-(void ) p_navigation{ Self.navigationItem.rightBarButtonItem = [UIbarbuttonitem alloc]initwithtitle:@ "SET" Style:uibarbuttonitemstyledone target:self Action: @selector (rightAction :)]; Self.navigationItem.leftBarButtonItem = [[Uibarbuttonitem alloc]initwithtitle:@ ' ADD ' style: Uibarbuttonitemstyledone target:self Action: @selector (leftaction:)];} -(void) Leftaction: (Uibarbuttonitem *) sender{ self.editstyle = Uitableviewcelleditingstyleinsert; [Self.rv.tableView setediting:!self.rv.tableview.editing animated:yes];} -(void) Rightaction: (Uibarbuttonitem *) sender{ Self.editstyle = Uitableviewcelleditingstyledelete ; [Self.rv.tableView setediting:!self.rv.tableview.editing animated:yes];} 2?: Specifies the line that can be edited-(BOOL) TableView: (UITableView *) TableView Caneditrowatindexpath: (Nsindexpath *) indexpath{ Return YES;} 3?: Specify TableView edited Style-(Uitableviewcelleditingstyle) TableView: (UITableView *) TableView Editingstyleforrowatindexpath: (Nsindexpath *) indexpath{ return Self.editstyle;} 4.: Finish editing ①: Modify data stream 1. [Self.dataarray[indexpath.section] removeobjectatindex:indexpath.row];2. [Self.dataarray[indexpath.section] insertobject:@ "New peole" AtIndex:indexPath.row + 1];②: Modify Ui1[self.rv.tableview Deleterowsatindexpaths:@[indexpath] Withrowanimation:uitableviewrowanimationright];2.nsindexpath *newIndex = [ Nsindexpath indexpathforrow:indexpath.row+1 insection:indexpath.section]; [Self.rv.tableView Insertrowsatindexpaths:@[newindex] Withrowanimation:uitableviewrowanimationautomatic];③: Full code:-(void) TableView: ( UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath: ( Nsindexpath *) indexpath{ if (Self.editstyle = = Uitableviewcelleditingstyledelete) { //1. Modify the data source [Self.dataarray[indexpath.section] removeobjectatindex:indexpath.row]; //2. Modify ui [sElf.rv.tableView Deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationright]; }else if (Self.editstyle = = Uitableviewcelleditingstyleinsert) { //Add [ Self.dataarray[indexpath.section] insertobject:@ "New peole" AtIndex:indexPath.row + 1]; Nsindexpath *newindex = [Nsindexpath indexpathforrow:indexpath.row+1 insection: indexpath.section]; [Self.rv.tableView Insertrowsatindexpaths:@[newindex] withrowanimation:uitableviewrowanimationautomatic];} 3.UItableView Mobile 1??: let TableView be in the edit state with the modification 2??: Make a movable line-(BOOL) TableView: (UITableView *) TableView Canmoverowatindexpath: (Nsindexpath *) indexpath{ return YES;} 3.: Complete Mobile ①: Modify data source//Take out data nsstring *temp = Self.dataarray[sourceindexpath.section][sourceindexpath.row]; //delete from the array [self.dataarray[ Sourceindexpath.section] removeobjectatindex:sourceindexpath.row]; //INSERT to the specified location [self.dataarray[destinationindexpath.section] insertobject:temp Atindex:destinationindexpath.row];②: Modify ui// Modify the UI Move Method [Self.rv.tableView moverowatindexpath:sourceindexpath Toindexpath: Destinationindexpath];③: Full code:-(void) TableView: (UITableView *) TableView Moverowatindexpath: (Nsindexpath *) Sourceindexpath Toindexpath: (Nsindexpath *) destinationindexpath{ //Take out data NSString *temp = self.dataarray[sourceindexpath.section][sourceindexpath.row]; //Remove from array [Self.dataarray[sourceindexpath.section] removeobjectatindex:sourceindexpath.row]; //inserting into the specified location [self.dataarray[destinationindexpath.section] insertobject:temp Atindex: destinationindexpath.row]; Modify the UI Move Method [Self.rv.tableView moverowatindexpath:sourceindexpath Toindexpath: Destinationindexpath];} ④: It is not recommended to limit cross-region-(Nsindexpath *) TableView: (UITableView *) TableView Targetindexpathformovefromrowatindexpath: ( Nsindexpath *) Sourceindexpath Toproposedindexpath: (Nsindexpath *) proposeddestinationindexpath{ if (sourceindexpath.section = = proposeddestinationindexpath.section) { Return proposeddestinationindexpath; }else { return sourceindexpath; }}4.uitableviewcontroller1??: First Sign up [Self.tableview Registerclass:[uitableviewcell class] forcellreuseidentifier:@ "Cell"];2??:-(UITableViewCell *) TableView: ( UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath { UITableViewCell *cell = [ TableView dequeuereusablecellwithidentifier:@ "Cell" forindexpath:indexpath]; cell.textLaBel.text = @ "123"; return cell;}
Attack UI---------------Uitableview&uitableview of the mobile