In my app I frequently get the warning
CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.
when I'm transitioning from a View Controller with a MKMapView to a TableViewController. Every once and a while this also throws the following exception:
Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <CALayerArray: 0x198e81f0> was mutated while being enumerated.'
My issue is that I never actually call anything from the CoreAnimation library directly in my code so the solution offered here wouldn't work for me.
I can't show you the exact code I'm using for confidentiality reasons, but here is the gist of what my code looks like for the transition:
MKMapView Side
UITabBarController *tbc = mapViewController.tabBarController;
UINavigationController *nav = [[tbc viewControllers]objectAtIndex:1];
ViewController *anotherController = [[nav viewControllers]objectAtIndex:0]; // not the final destination
[nav popToRootViewControllerAnimated:NO]; // pops to root without animation
[anotherController setSelectedEvent:event]; // sets which event to select before the segue
[tbc setSelectedIndex:1]; // changes the selected tab
[anotherController performSegueWithIdentifier:@"identifier" sender:nil]; // segues to the TableView
Segue from anotherController to tableViewController
if ([[segue identifier]isEqualToString:@"identifier"]) {
TableViewController *vc = segue.destinationViewController;
[vc setEvent:selectedEvent];
[vc.navigationItem setTitle:@"Title"];
[vc performSelectorInBackground:@selector(searchForAndScrollToEvent:) withObject:_selectedEvent];
}
Final Destination
-(void)searchForAndScrollToEvent:(Events*)event {
scroll_to_event_waiting_for_table_to_load = YES;
while (scroll_to_event_waiting_for_table_to_load) {
usleep(1000);
}
NSLog(@"segue completed");
EventListVirtualTable* virtualTable = [[EventListVirtualTable alloc]initWithViewController:self];
NSIndexPath *indexPath = [virtualTable indexPathOfEvent:event];
if (/*indexPath is bad*/) {
NSLog(@"NOT scrolling to: row %i section %i",indexPath.row,indexPath.section);
return;
}
[self performSelectorOnMainThread:@selector(scrollToAtIndexPath:) withObject:indexPath waitUntilDone:YES];
while (![[_tableView indexPathsForVisibleRows] containsObject:indexPath]) {
usleep(100);
}
[self performSelectorOnMainThread:@selector(selectCellAtIndexPath:) withObject:indexPath waitUntilDone:YES];
usleep(delay);
[self performSelectorOnMainThread:@selector(decselectCellAtIndexPath:) withObject:indexPath waitUntilDone:YES];
}
-(void)scrollToAtIndexPath:(NSIndexPath*)indexPath {
if(_dataController == nil){return;}
if (_tableView.numberOfSections == 0 || [self numberOfRowsInSection:indexPath.section] == 0 ) {
return;
}
[_tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
NSLog(@"scrolling to: row %i section %i",indexPath.row,indexPath.section);
}
Thanks everyone for taking the time to offer any responses or useful hints!