【发布时间】:2015-01-22 00:01:51
【问题描述】:
当我的 UITableView 处于编辑模式并按下删除按钮 (-) 时,我会在行中隐藏编辑按钮并显示删除和取消按钮。
如果按下取消按钮我很好,因为它会触发按钮的取消处理程序并且我会重新显示编辑按钮。
但是,如果用户在行内按下(不是取消或删除按钮),该行将退出删除模式,而不允许我显示编辑按钮。
当退出删除模式或在删除模式下按下行时,我是否可以检测到某些事件?
func tableView(tableView: UITableView!, editActionsForRowAtIndexPath indexPath: NSIndexPath!) -> [AnyObject]!
{
// hide the Edit button in this row
self.editButtons[indexPath.row].hidden = true
// create a Cancel button to abort delete
var cancelAction = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "Cancel", handler:
{(
action: UITableViewRowAction!, indexPath: NSIndexPath!) in
// if Cancel pressed, show the Edit button again
self.editButtons[indexPath.row].hidden = false
// reload the row to get rid of the Delete and Cancel buttons
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
return
})
var deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete",handler:
{(
action: UITableViewRowAction!, indexPath: NSIndexPath!) in
println("Delete not implemented")
return
})
return [deleteAction, cancelAction]
}
【问题讨论】:
标签: uitableview swift