Apple iOS UITableView left-sliding Delete custom Example

Source: Internet
Author: User

As we all know, UITableView's left-slip removal function is very cool, sometimes left-sliding features more than just delete one, sometimes there will be the other functions such as the top, this time we need to customize the left-slip

-(nsarray<uitableviewrowaction*>*) TableView: (UITableView *) TableView Editactionsforrowatindexpath: ( Nsindexpath *) Indexpath
{

Uitableviewrowaction *rowaction = [Uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledefault
title:@ "Cancel Collection" handler:^ (uitableviewrowaction * _nonnull action, Nsindexpath * _nonnull Indexpath) {
NSLog (@ "Favorites Click event");

}];

Uitableviewrowaction *rowaction2 = [Uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledefault
title:@ "Top" handler:^ (uitableviewrowaction * _nonnull action, Nsindexpath * _nonnull Indexpath) {
NSLog (@ "top button click event");

}];

Rowaction.backgroundcolor =rgb (215, 59, 16);

Nsarray *arr = @[rowaction,rowaction2];
return arr;
}

We can use Uitableviewrowaction to create objects, the following code block is clicked after the implementation of the method, created objects added to the array, so we can customize, color we can choose, very convenient.

Related Article

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.