可能重複:
change Table to Edit mode and delete Rows inside a normal ViewController如何從UITableView中刪除選定的行?
我想從的tableView刪除選中的行。我想向用戶提供功能,以便在他滑倒或輕敲手指時刪除該行。我知道編輯樣式,它提供了一個帶有-ve標誌的圓形紅色按鈕。
我曾嘗試這樣的代碼:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView beginUpdates];
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Do whatever data deletion you need to do...
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationTop];
}
[tableView endUpdates];
[tableView reloadData];
}
我得到的刪除按鈕,但是當我點擊它SIGABRT錯誤是存在的。
您可以檢查我的答案在這裏:http://stackoverflow.com/questions/14030944/how-can-i-delete-tableview-row-from-詳細視圖/ 14031052#14031052 – Bhavin