<分区>
Possible Duplicate:
change Table to Edit mode and delete Rows inside a normal ViewController
我想从 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 错误。