1, in IOS8 before, we realize TableView slide show Delete, top, more and so on the button, all need to implement themselves, in the IOS8 system has been written, as long as a proxy method and a class on the line
2, IOS8 protocol to a method, the return value is an array of Tableview:editactionforrowatindexpath: method, we can write several buttons inside the method, and then put in the array to return, The class of those buttons is uitableviewrowaction.
3, in the Uitableviewrowaction class. We can set the style of the button, display text, background color and button events (implemented within the block)
4, in the proxy method, we can often put several buttons to return to the array, the first place into the array of buttons to display at the far right, and finally put the display on the leftmost
5, if you set one or more buttons, the system with the Delete button disappeared
Set TableView to edit
-(BOOL) TableView: (UITableView *) TableView Shouldindentwhileeditingrowatindexpath: (Nsindexpath *) IndexPath
{ return
YES
}
How to use Uitableviewrowaction:
+ (Instancetype) Rowactionwithstyle: (uitableviewrowactionstyle) style title: (Nullable NSString *) title handler: (Void ( ^) (uitableviewrowaction *action, Nsindexpath *indexpath)) handler;
Rewrite Uitableviewdelegate's
-(Nullable nsarray<uitableviewrowaction *> *) TableView: (UITableView *) TableView Editactionsforrowatindexpath :(Nsindexpath *) Indexpath
Method.
-(Nsarray *) TableView: (UITableView *) TableView Editactionsforrowatindexpath: (Nsindexpath *) IndexPath {if ( indexpath.row==0) {//Add a Delete button deleterowaction = [uitableviewrowaction rowactionwithstyle:
uitableviewrowactionstyledestructive title:@ "Delete" handler:^ (uitableviewrowaction *action, NSIndexPath *indexPath) {
NSLog (@ "Click on Delete");
}]; else if (indexpath.row==1) {//Add a Delete button deleterowaction = [uitableviewrowaction rowactionwithstyle:
uitableviewrowactionstyledestructive title:@ "Delete" handler:^ (uitableviewrowaction *action, NSIndexPath *indexPath) {
NSLog (@ "Click on Delete");
}]; Add a Modify button morerowaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@ ' modify '
handler:^ (uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "clicked on Modify");
Morerowaction.backgroundeffect = [Uiblureffect Effectwithstyle:uiblureffectstyledark]; else if (indexpath.row==2) {//Add a Delete button deleterowaction = [uitableviewrowaction rowactionwithstyle: Uitableviewrowactionstyledestructive title:@ "Delete" handler:^ (uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "clicked Delete"); Add a Modify button morerowaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@ ' modify '
handler:^ (uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "clicked on Modify");
Morerowaction.backgroundeffect = [Uiblureffect Effectwithstyle:uiblureffectstyledark]; Add a send button sanrowaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@ "Send"
handler:^ (uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "click Send");
Sanrowaction.backgroundcolor=[uicolor Orangecolor]; else{//Add a Delete button deleterowaction = [Uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledestructive
title:@ "Delete" handler:^ (uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "clicked Delete"); Add a Modify button morerowaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@ ' modify ' handler:^ (Uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "click Modify");
Morerowaction.backgroundeffect = [Uiblureffect Effectwithstyle:uiblureffectstyledark]; Add a send button sanrowaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@ "Send"
handler:^ (uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "click Send");
Sanrowaction.backgroundcolor=[uicolor Orangecolor]; Add a send button OK = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@ ' OK key ' handler:^ (
Uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "click OK");}];
Ok.backgroundcolor=[uicolor Purplecolor]; ///Put the Set button in the array to return if (indexpath.row==0) {returns @[deleterowaction];} else if (indexpath.row==1) {return @[deleterowaction,morerowaction];} else if (indexpath.row==2) {return @[deleterowaction,morerowaction,sanrowaction];}
else if (indexpath.row==3) {return @[deleterowaction,morerowaction,sanrowaction,ok];} return nil; }
The above is a small set of iOS for you to introduce the use of TableView to achieve the right sliding display selection function of the relevant information, hope to help you.