IOS TableView Slide-off third-party controls

Source: Internet
Author: User

(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.