Skip to content

Instantly share code, notes, and snippets.

@kennylugo
Created February 21, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennylugo/4388fa16b37d845ced16 to your computer and use it in GitHub Desktop.
Save kennylugo/4388fa16b37d845ced16 to your computer and use it in GitHub Desktop.
Swipe Cells for More Actions( buttons )
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