Tableviewcell Swipe to Delete and more buttons (like Mail app in IOS7 or later)

Source: Internet
Author: User

In the iOS7 system mail app Tableviewcell a function Let us do tableview of comparison envy, is sliding cell, on the right there are two buttons, as follows:

Online on GitHub There are a lot of Daniel using custom Tableviewcell method to achieve this effect, and even stronger, such as the two-bit:

Https://github.com/CEWendel/SWTableViewCell

Https://github.com/daria-kopaliani/DAContextMenuTableViewController

But the custom implementation is really troublesome, finally found the Apple officially support this method, is a github on a Daniel, the OC Way to achieve:

https://gist.github.com/marksands/76558707f583dbb8f870

Apple's official API was called:

Func TableView (tableview:uitableview!, Editactionsforrowatindexpath indexpath:nsindexpath!), [anyobject]!

Daniel has been implemented with OC, I copy it Again is not interesting, so I use the swift language implementation, the code is as follows:

Func TableView (tableview:uitableview!, Editactionsforrowatindexpath indexpath:nsindexpath!), [anyobject]!{var moreaction:uitableviewrowaction= Uitableviewrowaction (Style:UITableViewRowActionStyle.Default, title:" More", handler:{(tableviewrowaction:uitableviewrowaction!, index:nsindexpath!), Voidinchprintln ("More Tap")}) Moreaction.backgroundcolor=Uicolor.lightgraycolor () var deleteaction:uitableviewrowaction= Uitableviewrowaction (Style:UITableViewRowActionStyle.Default, title:"Delete", handler: {(tableviewrowaction:uitableviewrowaction!, index:nsindexpath!), Voidinchprintln ("Delete Tap")}) Deleteaction.backgroundcolor=Uicolor.redcolor ()return[Deleteaction, Moreaction]}

This code runs normally under XCODE6-BETA5 and successfully outputs "more Tap" & "Delete Tap"

The rest of the code, you can complete their own, the rest of the usual way of operation, or you can refer to the code of the Daniel on GitHub.

Now just swipe left with a button, if the right swipe also has the button is good, if can be simple implementation, I am writing up.

Tableviewcell Swipe to Delete and more buttons (like Mail app in IOS7 or later)

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.