Ich habe eine reguläre Uitableview Setup mit und derzeit, wenn ein Benutzer nach links wischt, wird die Aktion angezeigt. Ich möchte eine Aktion hinzufügen, wenn ein Benutzer nach rechts wischt, aber ich kann nirgendwo in der Apple-Dokumentation oder online finden, wie dies zu tun ist. Irgendwelche Gedanken?Hinzufügen von Aktion beim Wischen rechts auf UITABLEVIEW in Swift
Hier ist meine aktuelle Setup:
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return expandedIndexPaths.contains(indexPath) ? 200.0 : 50.0
}
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// the cells you would like the actions to appear needs to be editable
return true
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
}
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let share = UITableViewRowAction(style: .Normal, title: "Done") { action, index in
let currentElement = self.tipArray[indexPath.row]
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let context: NSManagedObjectContext = appDel.managedObjectContext
var ent = NSEntityDescription.entityForName("Tips", inManagedObjectContext: context)
self.repurposeManagedObjectContext("Tips", forAttribute: "rowNumber", object: indexPath.row)
self.tipArray.insert(currentElement, atIndex: self.tipArray.count)
self.tipArray.removeAtIndex(indexPath.row)
self.tableView.reloadData()
}
// let categorize = UITableViewRowAction(style: UITableViewRowActionStyle, title: <#T##String?#>, handler: <#T##(UITableViewRowAction, NSIndexPath) -> Void#>)
share.backgroundColor = UIColor.blueColor()
return [share]
}