[英]“no index path for table cell being reused” leading to app crash
I have two views for my cells. 我对自己的牢房有两种看法。 On tap I toggle between a expanded and collapsed views. 在点击时,我在展开和折叠视图之间切换。 I have two separate custom tableview cells
. 我有两个单独的自定义tableview cells
。
It works fine if I use [tableView reloadData]
but app crashes when I use reloadRowsAtIndexPaths
. 如果我使用[tableView reloadData]
但是当我使用reloadRowsAtIndexPaths
时应用崩溃。 It works fine without using breakpoints, although I suspect it might just be harder to reproduce without breakpoints. 它可以在不使用断点的情况下正常运行,尽管我怀疑没有断点可能很难复制。 I have a UIWebView
in my cell, to get taps on the UIWebView
I am using UITapGestureRecognizer
. 我的单元格中有一个UIWebView
,以便在我正在使用UITapGestureRecognizer
的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];
}
Code reaches willdisplaycell but it crashes after that. 代码到达willdisplaycell,但此后崩溃。 I just committed this code and on my colleague's machine it only shows "no index path for table cell being reused" without any crash. 我只是提交了这段代码,在我同事的机器上,它仅显示“没有重用表单元的索引路径”而没有崩溃。
The only error on the console is this " no index path for table cell being reused". 控制台上唯一的错误是“没有表单元被重用的索引路径”。 In the code it shows EXC_BAD_ACCESS in the main.m file. 在代码中,它在main.m文件中显示EXC_BAD_ACCESS。 There is no crash report in Library/Logs/DiagnosticReports. 库/日志/诊断报告中没有崩溃报告。
On tailing the /var/log/system.log I get. 在跟踪/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.
You can try to disable touches on the webView and intercept the touches in the didSelectRow. 您可以尝试在webView上禁用触摸,并在didSelectRow中拦截触摸。
Also instead of [tableView reloadData]
try using: 另外,不要使用[tableView reloadData]
尝试使用:
[tableView beginUpdates];
[tableView endUpdates];
It almost always works better for collapsing tableviews. 它对于折叠表视图几乎总是更好地工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.