【发布时间】:2014-04-09 03:49:04
【问题描述】:
将我的代码精简到最基本的部分,当我按下删除按钮时,应用程序崩溃了。有什么想法吗?
这里是删除代码。正如我所说,最基本的。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove the deleted object from your data source.
//If your data source is an NSMutableArray, do this
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
【问题讨论】:
-
什么是崩溃错误?您正在从表格视图中删除行,但并未从数据源中删除项目。
-
从数据源中删除对象完成了这项工作。谢谢老哥!
标签: ios objective-c uitableview delete-row