简体   繁体   中英

“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 .

It works fine if I use [tableView reloadData] but app crashes when I use 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 .

- (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. 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. There is no crash report in Library/Logs/DiagnosticReports.

On tailing the /var/log/system.log I get.

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.

Also instead of [tableView reloadData] try using:

[tableView beginUpdates];
[tableView endUpdates];

It almost always works better for collapsing tableviews.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM