【发布时间】:2013-01-07 06:36:06
【问题描述】:
可能重复:
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 错误。
【问题讨论】:
-
你可以在这里查看我的答案:stackoverflow.com/questions/14030944/…
标签: iphone ios uitableview ios4