Skip to content

Instantly share code, notes, and snippets.

@BradB132
Created May 31, 2015 14:42
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 BradB132/a03c42340f40d2e6864c to your computer and use it in GitHub Desktop.
Save BradB132/a03c42340f40d2e6864c to your computer and use it in GitHub Desktop.
FirstAppInSwift-9
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
var myAction = UITableViewRowAction(style: .Default, title: "My Custom Action", handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
//block that runs when 'My Custom Action' button is tapped
})
//it's useful to differentiate each button with color
myAction.backgroundColor = UIColor.lightGrayColor()
//create additional actions here
return [myAction /* add additional actions to this array */]
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
//note: we need this empty implementation for 'editActionsForRowAtIndexPath' to work
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment