“没有重复使用表格单元格的索引路径”导致应用程序崩溃

时间:2013-12-19 11:38:25

标签: ios objective-c uitableview uiwebview

我的细胞有两种观点。点击后,我在展开和折叠视图之间切换。我有两个单独的自定义tableview cells

如果我使用[tableView reloadData]它可以正常工作,但是当我使用reloadRowsAtIndexPaths时应用程序崩溃。它在没有使用断点的情况下工作正常,但我怀疑在没有断点的情况下再现可能更难。我的单元格中有一个UIWebView,可以点击UIWebView我正在使用UITapGestureRecognizer

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;

}

- (void)tapAction:(UITapGestureRecognizer *)sender {
    UIView* cell = sender.view;
    while (![cell isKindOfClass:[UITableViewCell class]]) {
        cell = [cell superview];
    }
    NSIndexPath* i = [self.tableView indexPathForCell:(UITableViewCell *)cell];
    [self didSelectRowAtIndexPath:self.tableView ForIndexPath:i];
}

代码到达将显示,但在此之后它会崩溃。我刚刚提交了这个代码并且在我的同事的机器上它只显示“没有表格单元被重用的索引路径”而没有任何崩溃。

控制台上唯一的错误就是“没有重复使用表格单元的索引路径”。在代码中,它在main.m文件中显示EXC_BAD_ACCESS。 Library / Logs / DiagnosticReports中没有崩溃报告。

关于尾随/var/log/system.log我得到了。

Dec 23 23:59:55 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50272]: Got a 'k' packet, killing the inferior process.
Dec 23 23:59:55 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50272]: Sending ptrace    PT_KILL to terminate inferior process.
Dec 23 23:59:55 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50272]: 1 +0.000000 sec   [c460/0303]: error: ::ptrace (request = PT_THUPDATE, pid = 0xc45d, tid = 0x1a03, signal = 0) err =   Resource busy (0x00000010)
Dec 23 23:59:55 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50272]: 2 +0.004694 sec [c460/0303]: error: ::task_info ( target_task = 0x1603, flavor = TASK_BASIC_INFO, task_info_out => 0x7fff52208f90, task_info_outCnt => 10 ) err = (ipc/send) invalid destination port (0x10000003)
Dec 23 23:59:55 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50272]: Waited 0 ms for process to be reaped (state = Exited)
Dec 23 23:59:56 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50333]: debugserver-300.2 for x86_64.
Dec 23 23:59:56 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50333]: Listening to port 31030 for a connection from localhost...
Dec 23 23:59:56 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50333]: Got a connection, waiting for process information for launching or attaching.
Dec 23 23:59:56 Ankushs-MacBook-Pro kernel[0]: warning: debugserver(50333) performed out-of-band resume on FormulaApp(50332)
Dec 23 23:59:57 Ankushs-MacBook-Pro.local com.apple.debugserver-300.2[50333]: Attach succeeded, ready to debug.

1 个答案:

答案 0 :(得分:1)

您可以尝试在webView上禁用触摸并拦截didSelectRow中的触摸。

而不是[tableView reloadData]尝试使用:

[tableView beginUpdates];
[tableView endUpdates];

它几乎总能更好地折叠表格视图。