基本上,我有一個自定義表格視圖單元格列出了潛在的員工。這個單元格包含一些標籤和一個按鈕。我想是的按鈕來刪除單元格,但所有我能找到的是:在表格視圖單元格中使用按鈕出列單元格
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
numbers.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
}
}
只允許你刪除單元格,如果你輕掃,然後選擇「刪除」
我想我應該在我的tableViewController.swift文件中創建一個函數,它將刪除給定行處的單元格,並在我的自定義單元格類中創建一個將調用該函數的IBAction。
在給定的行刪除單元格的函數是什麼樣的?但是在這種情況下,單元格是否也知道它在哪個行或者是tableViewController的作業?
看到這個:http://stackoverflow.com/questions/8983094/how-to-enable-swipe-to-delete-cell-in-a-tableview – Koen