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)