(To my file, download the "TableView Third party Control"), using the following method:
In the TableView. m, set the cell's method, the case code is as follows, where Easeconversationcell inherits from Lysideslipcell:
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {nsstring*cellidentifier =[Easeconversationcell Cellidentifierwithmodel:nil]; Easeconversationcell*cell = (Easeconversationcell *) [TableView Dequeuereusablecellwithidentifier:cellidentifier]; if(Cell = =Nil) {Cell=[[Easeconversationcell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } Cell.consultmodel=Self.dataarray[indexpath.section];
Add a button after slide Kdbutton*DELETEBTN =[cell Rowactionwithstyle:lysideslipcellactionstylenormal Title:nil]; Deletebtn.index=Indexpath.row; Deletebtn.section=indexpath.section; Deletebtn.backgroundcolor=[Uicolor Redcolor]; [Deletebtn Setbackgroundimage:kuiimage (@"Delete") Forstate:uicontrolstatenormal]; [Deletebtn addtarget:self Action: @selector (DELETEBTN:) forcontrolevents:uicontroleventtouchupinside]; [Cell SETRIGHTBUTTONS:@[DELETEBTN]];//you can pass multipleCell.selectionstyle =Uitableviewcellselectionstylenone; returncell;}
As follows:
(Reference code: Mei Yip B-terminal-mybconsultviewcontroller.m)
The advantage of this control is that you can monitor the action of the cell side-slip, such as the need to change the cell color after the slide, this control can be achieved, in the LYSIDESLIPCELL.M: monitoring the following two methods:
- (void) Hiddensideslipbutton {//action after slide-back recovery if(_containleftconstraint.constant = =0)return; [Self closealloperation]; _containleftconstraint.constant= _sideslipleftconstraint.constant =0; [UIView animatewithduration:0.2Delay0Options:uiviewanimationoptioncurvelinear animations:^{[Self layoutifneeded]; } Completion:^(BOOL finished) {[Self openalloperation]; }]; _backgroundview.backgroundcolor= Uicolorfromrgb (0xf7f7f7); _backgroundview.frame= CGRectMake (Ten,0, Kscreenw- -, -);}- (void) Showsideslipbutton {//the operation after skidding[self closealloperation]; _containleftconstraint.constant= _sideslipleftconstraint.constant =-cgrectgetwidth (_sideslipview.frame); [UIView animatewithduration:0.2Delay0Options:uiviewanimationoptioncurvelinear animations:^{[Self layoutifneeded]; } Completion:^(BOOL finished) { for(Lysideslipcell *cellinchself.tableView.visibleCells)if([Cell Iskindofclass:lysideslipcell.class]) {cell.userinteractionenabled=YES; } }]; _backgroundview.backgroundcolor= Uicolorfromrgb (0xe7f8ff); _backgroundview.frame= CGRectMake (Ten,0, Kscreenw-Ten, -);}
:
IOS TableView Slide-off third-party controls