#import "ViewController.h" #import "Swift_oc-swift.h" @interface Viewcontroller () <uitableviewdelegate, Uitableviewdatasource> @property (Weak, nonatomic) Iboutlet UITableView *tableview; @property (Nonatomic,strong) Nsmutablearray *datasource; @end @implementation viewcontroller-(void) viewdidload {[Super viewdidload]; Self.datasource = [Nsmutablearray arraywithobjects:@ "1", @ "2", @ "3", @ "4", @ "5", nil]; Self.tableView.delegate = self; Self.tableView.dataSource = self; Swift *swift = [[Swift alloc]init]; OC calls the Swift method ("Swift_oc-swift.h")//[Swift demofunction]; Swift calls OC method (Swift_oc-bridging-header)//[Swift SWIFTFETCTIONOBJECTC];} -(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 1;} -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{return Self.dataSource.count;} -(uitableviewcell*) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{ UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:@ "Cell"]; if (!cell) {cell = [[UITableViewCell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:@ "Cell"]; } Cell.textLabel.text = Self.datasource[indexpath.row]; return cell;} The following implementation of the relevant Code////////////////////////////-(BOOL) TableView: (UITableView *) TableView Caneditrowatindexpath: (Nsindexpath *) indexpath{return YES;} Returns only one button before returning IOS8//-(Uitableviewcelleditingstyle) TableView: (UITableView *) TableView Editingstyleforrowatindexpath: (Nsindexpath *) indexpath//{//return uitableviewcelleditingstyledelete;//}////-( void) TableView: (UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath: (Nsindexpath *) indexpath{////if (Editingstyle ==uitableviewcelleditingstyledelete) {//[s Elf.datasource removeobjectatindex:indexpath.row];//[Self.tableview Deleterowsatindexpaths:@[indexpath] Withrowanimation:uitableviewrowanimationautomatic];//}//}//ios8 can return multiple buttons later-(Nsarray *) TableView: (UITableView *) TableView Editactionsforrowatindexpath: (Nsindexpath *) indexpath{//Set Delete button uitableviewrowaction *deleterowaction = [UITable Viewrowaction rowactionwithstyle:uitableviewrowactionstyledestructive title:@ "Delete" handler:^ (UITableViewRowAction * Action,nsindexpath *indexpath) {[Self.datasource removeObjectAtIndex:indexPath.row]; [Self.tableview deleterowsatindexpaths:@[indexpath]withrowanimation:uitableviewrowanimationautomatic]; }]; Set Favorite button Uitableviewrowaction *collectrowaction = [uitableviewrowaction rowactionwithstyle: Uitableviewrowactionstyledefault title:@ "Favorites" handler:^ (uitableviewrowaction *action,nsindexpath *indexPath) {NSLog (@ "collection"); }]; Set the sticky button uitableviewrowaction *toprowaction = [uitableviewrowaction rowactionwithstyle: Uitableviewrowactionstyledefault title:@ "pinned" handler:^ (uitableviewrowaction *action,nsindexpath *indexPath) { [Self.datasource ExchangeObjectAtIndex:indexPath.row withobjectatindex:0]; Nsindexpath *firstindexpath = [Nsindexpath indexpathforrow:0 inSection:indexPath.section]; [TableView Moverowatindexpath:indexpath Toindexpath:firstindexpath]; }]; Set the sticky button uitableviewrowaction *testrowaction1 = [uitableviewrowaction rowactionwithstyle: Uitableviewrowactionstyledefault title:@ "Test 1" handler:^ (uitableviewrowaction *action,nsindexpath *indexPath) {NSLo G (@ "Test 1"); }]; Uitableviewrowaction *testrowaction2 = [Uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledefault title:@ "Test 2" handler:^ (uitableviewrowaction *action,nsindexpath *indexpath) {NSLog (@ "Test 2"); }]; Uitableviewrowaction *testrowaction3 = [Uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledefault title:@ "Test 2" handler:^ (uitableviewrowaction *action,nsindexpath *indexpath) {NSLog (@ "Test 3"); }]; Collectrowaction.backgroundeffect = [Uiblureffect effecTwithstyle:uiblureffectstylelight]; Toprowaction.backgroundcolor = [Uicolor Bluecolor]; Collectrowaction.backgroundcolor = [Uicolor Graycolor]; The test can return an unlimited number of .... return @[deleterowaction,collectrowaction,toprowaction,testrowaction1,testrowaction2, TestRowAction3];}
:
IOS cell Left slide multiple function buttons (IOS8 support later)