2
UITableView가 편집 모드이고 삭제 단추 (-)를 누르면 행의 편집 단추를 숨기고 삭제 및 취소 단추를 표시합니다.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]
}
올바른 대답입니다. 편집 모드를 종료 할 때이 기능을 누르면됩니다. 그러나 나는 Swift를 처음 사용하기 때문에 View Controller에서 대리자를 설정하고 호출하는 방법을 알아야합니다. – billd