Created
February 21, 2016 21:10
-
-
Save kennylugo/4388fa16b37d845ced16 to your computer and use it in GitHub Desktop.
Swipe Cells for More Actions( buttons )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { | |
let shareAction = UITableViewRowAction(style: .Default, title: "SHARE") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in | |
let shareMenu = UIAlertController(title: nil, message: "Share using one of the below", preferredStyle: .ActionSheet) | |
shareMenu.addAction(UIAlertAction(title: "FaceBook", style: .Default, handler: nil)) | |
shareMenu.addAction(UIAlertAction(title: "Twitter", style: .Default, handler: nil)) | |
shareMenu.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)) | |
self.presentViewController(shareMenu, animated: true, completion: nil) | |
} | |
let deleteAction = UITableViewRowAction(style: .Default, title: "DELETE") { (ACTION: UITableViewRowAction, indexPath: NSIndexPath) -> Void in | |
self.restaurantNames.removeAtIndex(indexPath.row) | |
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Bottom) | |
} | |
shareAction.backgroundColor = UIColor.orangeColor() | |
deleteAction.backgroundColor = UIColor.cyanColor() | |
return [shareAction, deleteAction] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment