2016-03-29 8 views
3

右にスワイプしたときに表示されるテーブルビュー(screenshot)の編集メニューを閉じるオプションがあるかどうかを知りたいと思います。私はすぐに私はオプションを選択すると、私のケースでは、私はオプションのいずれかを選択しても閉じないメニューを閉じるにしたい。画面上の任意の場所を選択したときにのみ閉じます。以下はIOS Swift TableViewインデックス行の行の編集操作

あなただけの特定のセルをリロードする必要があり、それがオプションを閉じます

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 

} 

func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -> Bool { 
    return true 
} 

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? 
{ 
    let update = UITableViewRowAction(style: .Normal, title: "Update") { action, index in 
     print("update") 
    } 
    let delete = UITableViewRowAction(style: .Default, title: "Delete") { action, index in 
     print("Delete") 

    } 
    return [delete, update] 
} 

enter image description here

+0

アクションブロックで 'self.tableView.setEditing(false、animated:true)'を呼び出すと、後で有効にする必要があるかもしれません。 – Tj3n

+0

@ Tj3nありがとうございました – vanquish

答えて

2

を使用してイム私のコードです。

このため、次のコードを使用すると問題を解決できる場合があります。

self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top) 

また、あなたが

self.tableView.setEditing(false, animated: true) 

ハッピーコーディングを使用することができます。

+0

ありがとうございました。 – vanquish

関連する問題