#pragmaMark-view lifecycle-(void) viewdidload {[Super viewdidload]; Self.view.backgroundColor=[Uicolor Whitecolor]; [Self.tableview Registerclass:[uitableviewcellclass] forcellreuseidentifier:reuseidentifier];}#pragmaMark-uitableviewdatasource methods-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {returnSelf.dataArray.count;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {UITableViewCell*cell =[TableView Dequeuereusablecellwithidentifier:reuseidentifier]; Cell.textLabel.text=Self.dataarray[indexpath.row]; returncell;}#pragmaMark-uitableviewdelegate methods-(nsarray<uitableviewrowaction *> *) TableView: (UITableView *) TableView Editactionsforrowatindexpath: (Nsindexpath *) Indexpath {uitableviewrowaction*deleteaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledestructive title:@"Delete"handler:^ (uitableviewrowaction * _nonnull action, Nsindexpath *_nonnull Indexpath) {NSLog (@"Delete-%@", @ (Indexpath.row)); [Self.dataarray RemoveObjectAtIndex:indexPath.row]; [Self.tableview Deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationfade]; }]; Uitableviewrowaction*otheraction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@"pinned"handler:^ (uitableviewrowaction * _nonnull action, Nsindexpath *_nonnull Indexpath) {NSLog (@"pinned-%@", @ (Indexpath.row)); [Self.dataarray exchangeObjectAtIndex:indexPath.row Withobjectatindex:0]; Nsindexpath*toindexpath = [Nsindexpath indexpathforrow:0InSection:indexPath.section]; [Self.tableview Moverowatindexpath:indexpath Toindexpath:toindexpath]; }]; return@[deleteaction, otheraction];}#pragmaMark-getter methods-(Nsmutablearray *) DataArray {if(!_dataarray) {_dataarray=[Nsmutablearray array]; [_dataarray addobjectsfromarray:@[@"kingdev:row:0", @"kingdev:row:1", @"Kingdev:row:2", @"Kingdev:row:3", @"Kingdev:row:4", @"Kingdev:row:5", @"Kingdev:row:6", @"Kingdev:row:7", @"Kingdev:row:8", @"Kingdev:row:9", @"kingdev:row:10", @"kingdev:row:11", @"Kingdev:row:12" ]]; } return_dataarray;}
"Kingdev"
After IOS8, the uitableviewrowaction implements sliding multiple buttons