从 uitableview 崩溃中删除行
我只是尝试使用以下代码从 UITableView
中删除一行:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
问题是我的应用程序崩溃了。 (GDB:程序接收信号:“EXC_BAD_INSTRUCTION”。) 有人知道为什么吗?
I simply try to delete a row from a UITableView
with the following code:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
The problem is that my app crashes. (GDB: Program received signal: "EXC_BAD_INSTRUCTION".)
Anybody know why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要将
indexPath.section
返回的数字更改为比删除之前小 1。
You probably need to change the number returned in
for the
indexPath.section
to be one lower than before the deletion.