Custom meaning cell swipe left and right to add a self-defined button

Source: Internet
Author: User
Scheme one   left slip support text first pay the iOS8 with the cell sliding  
The main code #pragma mark displays more buttons when the swipe gesture deletes a line-(Nsarray *) TableView: (UITableView *) TableView Editactionsforrowatindexpath: (Nsindexpath *) Indexpath {//Add a Delete button uitableviewrowaction *deleterowaction = [UITab Leviewrowaction rowactionwithstyle:uitableviewrowactionstyledestructive title:@ "Delete" handler:^ (
        
Uitableviewrowaction *action, Nsindexpath *indexpath) {NSLog (@ "clicked Delete"); 1.
Update data//[_alldataarray RemoveObjectAtIndex:indexPath.row]; 2.
    Update UI//[TableView deleterowsatindexpaths:@[indexpath]withrowanimation:uitableviewrowanimationautomatic];
    }];

    Deleterowaction.backgroundcolor = [Uicolor Bluecolor];

    Deleterowaction.backgroundeffect = [Uiblureffect Effectwithstyle:uiblureffectstyledark]; Remove a sticky button//uitableviewrowaction *toprowaction = [uitableviewrowaction rowactionwithstyle: Uitableviewrowactionstyledefault title:@ "pinned" handler:^ (uitableviewrowaction *action, NSIndexPath *indexPath) {//NS Log (@ "click"); //1.
Update data//[_alldataarray exchangeObjectAtIndex:indexPath.row withobjectatindex:0]; //2.
Update UI//Nsindexpath *firstindexpath = [Nsindexpath indexpathforrow:0insection:indexpath.section];
[TableView MoveRowAtIndexPath:indexPathtoIndexPath:firstIndexPath];
//    }];
    
Toprowaction.backgroundcolor = [Uicolor Bluecolor]; Add a more button//uitableviewrowaction *morerowaction = [Uitableviewrowaction rowactionwithstyle:uitableviewrowactio        
Nstylenormal title:@ "More" handler:^ (uitableviewrowaction *action, Nsindexpath *indexpath) {//NSLog (@ "click More");//
[TableView Reloadrowsatindexpaths:@[indexpath]withrowanimation:uitableviewrowanimationmiddle];
//    }];
    
    Morerowaction.backgroundeffect = [Uiblureffect Effectwithstyle:uiblureffectstyledark];
Put the Set button in the array to return a few to add a few, but pay attention to add order return @[deleterowaction]; }
Scenario Two: Left slide support picture text
View Open Source Library: Mgswipetablecell (often updated) (if not meet the requirements can be again encapsulated modified, such as my button needs to show two different pictures to indicate the different state of fine varieties) or Swtableviewcell (relatively early, no maintenance) scheme four: Left slide support text/Picture (can be seen as a hands-on implementation) only the idea: their own xib package to add a button in the cell's right boundary, the normal situation can not see, but the cell's add left slide right gesture, the cell to the left, the cell to the right of the button is visible, this You can add several buttons if you like. Notice that the gesture is going through the cell, otherwise it may be blocked by the cell's own gesture, without the desired result. Scenario Three: Left slide support text picture (can be seen as a hands-on implementation) Source: Ellen Shapiro translation Source: Nixzhu (@nixzhu) Welcome to share the original to Bole headlines

Apple introduces a new user interface scheme via the IOS 7 mail app-Swipe left to display a menu with multiple actions. This tutorial will show you how to make one of these Table view cells without having to get bogged down by nested Scroll view. If you don't yet know what a sliding Table View Cell means, look at Apple's Mail app:

You might think that since Apple has shown this option, it should have been open to developers. After all, how hard can it be? Unfortunately, they only let developers use the Delete button-at least for the time being. If you want to add another button, or change the text or color on the Delete button, you have to do it yourself.

Translator Note: In fact, the text can be modified, but the color is really not.

In this tutorial, you will first learn how to implement a simple swipe to delete an action (Swipe-to-delete action), and then we then implement the swipe to perform the operation (swipe-to-perform-actions). This will require you to delve into the structure of IOS 7 UITableViewCell in order to replicate the behavior we need. You'll use some of the techniques I personally like to check the view hierarchy: Paint the View and use the Recursivedescription method to print out the view hierarchy. Start

Open Xcode and go to file\new\project ... and select Master-detail application as follows:

Name the project Swipeablecell and fill in your own Organization name and company Identifier. Select IPhone as the target device and make sure that use Core Data is not selected, as shown in:

For proof of such a concept project, you'd better make sure the data model is as simple as possible.

Open masterviewcontroller.m and find Viewdidload. Replace the default setting of Navigation Bar Items with the following implementation:

1 2 3) 4 5

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.