iphone - 从 uitableview 崩溃中删除行

标签 iphone uitableview crash row

我只是尝试使用以下代码从 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”。) 有人知道为什么吗?

最佳答案

您可能需要更改返回的数字

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section

使 indexPath.section 比删除之前小 1。

关于iphone - 从 uitableview 崩溃中删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2229626/

相关文章:

iphone - Assets 目录 ImageSet - 编辑 Contents.json

iOS - 在更新到新版本时保留旧的 sqlite 数据库

ios - swift 2.0,UITableView : cellForRowAtIndexPath returning nil for non-visible cells

iphone - 如何从客户那里获取 iPhone 崩溃日志?

iphone - Wi-fi 抓包 IVS。

iphone - 获取GKLocalPlayer上面两个好友的分数

ios - UITableViewCell 并在单元格中重新定位 UILabels

ios - UIView 与 UITableView 和 UIGestureRecognizer 突然停止手势识别

macos - 如何在 Mac 应用程序中调试 EXC_BAD_ACCESS (SIGSEGV)?

ios - SpriteKit : Weird crash when preloading texture atlases