QQ Contact Left Slide Delete function

Source: Internet
Author: User

Local Refresh

nsarray *indexpaths = @[

[nsindexpath indexpathforrow:0 insection:0],

[nsindexpath indexpathforrow:1 insection:0]

];

[self. TableView reloadrowsatindexpaths: indexpaths withrowanimation:uitableviewrowanimationleft ];

#pragma mark- click on the button

-(ibaction) Remove {

// Enter edit mode

self.tableView.editing =!self.tableview.isediting;

[self. TableView setediting:! Self. TableView. Isediting animated:YES];

}

#pragma mark-uitableviewdelegate

/**

* as long as this method is implemented, it has the left slide delete function

* clicking the Delete button that appears on the left will call this

*/

-(void) TableView: (uitableview *) TableView Commiteditingstyle: ( Uitableviewcelleditingstyle) Editingstyle forrowatindexpath: (nsindexpath *) Indexpath

{

NSLog(@ "commiteditingstyle--");

[self. Winearray removeobjectatindex: Indexpath. Row];

[self. TableView deleterowsatindexpaths:@[indexpath] withrowanimation: uitableviewrowanimationtop];

}

/**

* Modify The text of the default Delete button

*/

-(NSString *) TableView: (UITableView *) TableView Titlefordeleteconfirmationbuttonforrowatindexpath: (Nsindexpath * ) Indexpath

//{

return @ " delete ";

//}

-(Nsarray<uitableviewrowaction *> *) TableView: (uitableview *) TableView Editactionsforrowatindexpath: (nsindexpath *) indexpath

{

self.tableView.editing = YES;

uitableviewrowaction *action = [uitableviewrowaction rowactionwithstyle: Uitableviewrowactionstylenormal title:@ " attention " handler: ^ ( Uitableviewrowaction * _nonnull action, nsindexpath * _nonnull indexpath) {

[Self.tableview Reloaddata];

[Self.tableview Reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationright];

// exit edit mode

self. TableView. Editing = NO;

}];

uitableviewrowaction *action1 = [uitableviewrowaction rowactionwithstyle: Uitableviewrowactionstyledestructive title:@ " Delete " handler: ^ ( Uitableviewrowaction * _nonnull action, nsindexpath * _nonnull indexpath) {

[self. Winearray removeobjectatindex: Indexpath. Row];

[self. TableView deleterowsatindexpaths:@[indexpath] withrowanimation: uitableviewrowanimationautomatic];

}];

return @[action1,action];

}

@end

QQ Contact Left Slide Delete function

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.