0

在Swift中。如何添加滑動刪除單元格(仍然顯示刪除的顏色和標籤),但是隨着滑動操作結束,它執行刪除操作。我看到在別處回答了同樣的問題,但是是爲了客觀的目的。我不確定swift是否有任何新的實現。任何幫助都會很棒。Swipe刪除單元格而不必按下刪除按鈕Swift

感謝

+0

你最終找到答案嗎? –

回答

0

你可以使用比基本UITableView實現的其它兩種方法:

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

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 
    if editingStyle == .Delete { 
     objects.removeAtIndex(indexPath.row) 
     tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) 
    } 
} 
+0

如果我沒有弄錯,該代碼會顯示刪除按鈕,但用戶仍然需要觸摸刪除按鈕才能刪除它。我正在尋找很多郵件應用中的內容,在這些應用中,您輕掃並放開並執行操作。例。 Google收件箱。滑動一種方式歸檔。滑動另一個以打盹。或者在X軸上更大/更長的滑動來刪除。有道理? – MBTDesigns