can't delete cell in searchResultsTableView
-
I can't remove the cell in the rolling table in the usual yoke, and after the search, it makes a mistake.
Assertion failure in -[UISearchResultsTableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.29.5/UITableView.m:1720 2015-12-14 09:29:04.907 Unirenter[552:178776] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).' *** First throw call stack: (0x220e185b 0x337a2dff 0x220e1731 0x22e72ddb 0x26408269 0x264218c9 0x264217a3 0x8ab6b 0x26555d97 0x26692ba5 0x2624d5e1 0x2624d571 0x26235487 0x2624cec1 0x26206fe7 0x26245c89 0x2624543b 0x262162f1 0x26214937 0x220a47c7 0x220a43b7 0x220a271f 0x21ff50d9 0x21ff4ecd 0x2b36aaf9 0x2627e2dd 0x8f031 0x33ef0873) libc++abi.dylib: terminating with uncaught exception of type NSException
Here's the disposal code
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Удалить" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
if (tableView == self.tableView) { [self deleteMessage:[_id_message objectAtIndex:indexPath.row]]; [_id_message removeObjectAtIndex:indexPath.row];//or something similar to this based on your data source array structure [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else { NSLog(@"Удаляем id -%d ",[self TitleWithId:[_filteredCandyArray objectAtIndex:indexPath.row]]); // [_id_message removeObjectAtIndex:[self TitleWithId:[_filteredCandyArray objectAtIndex:indexPath.row]]]; [self.searchDisplayController.searchResultsTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; }
This code is in the method.
tableView editActionsForRowAtIndexPath
I've tried everything.
-
I found a reason, in a simple table, I removed the element first and then updated it and left it in the rolling table. Added the method
[_filteredCandyArray removeObjectAtIndex:indexPath.row];
before[self.searchDisplayController.searchResultsTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
And it worked.