0
votes

When running my program, I receive the following crash error:

Assertion failure in -[UISearchDisplayController setActive:animated:], /SourceCache/UIKit_Sim/UIKit-2903.23/UISearchDisplayController.m:1275

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'search contents navigation controller must not change between -setActive:YES and -setActive:NO'

The error occurs when I hit cancel on a search bar, after the following block of code:

-(void)searchBarCancelButtonClicked:(UISearchBar *) searchBar {
    [self.searchBar resignFirstResponder];
    _displayRowData = nil;
    [_sdc.searchResultsTableView reloadData];

    [self.navigationController popViewControllerAnimated:NO];
}

Note: this error goes away when I switch to:

[self.navigationController popViewControllerAnimated:YES];

This error persists even when I comment out the only call I have to -setActive.

What is the proper way to popViewController without animation? There is another view controller on the navigation stack when this is called. I cannot use dismissViewController because I need to keep everything on the navigation stack. I just want a clean transition to my previous view controller.

1

1 Answers

0
votes

SOLVED. Calling the following before popping fixed my problem:

[_sdc setActive:NO animated:YES];
[self.navigationController popViewControllerAnimated:NO];