【发布时间】:2016-08-17 06:14:13
【问题描述】:
我想单击单元格,然后调用编辑操作。但是,我不确定如何实现手动调用滑动。我认为这个答案有解决方案,但我不太了解目标C。https://stackoverflow.com/a/29839673/5737856
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// swipe
//tableView(tableView, editActionsForRowAtIndexPath: indexPath) or other functions???
}
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: " Edit " , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
print("EDIT")
})
editAction.backgroundColor = UIColor.blueColor()
let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete" , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
print("DELETE")
})
return [deleteAction, editAction]
}
【问题讨论】:
标签: swift uitableview swipe didselectrowatindexpath