Table view is no longer a search for ResultsTableView after returning from a detailed view

I am using UISearchDisplayController based on this tutorial: http://developer.apple.com/library/ios/#samplecode/TableSearch/Introduction/Intro.html

I have a table view in a navigation controller with this search controller. As usual, you can perform a search, click on the search result and go to the detailed view.

I am using code like the one below to determine if the current table view is a search of ResultsTableView.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if(tableView == self.searchDisplayController.searchResultsTableView)
        return 1;
    else
        return [self.arrCharacters count];
}

My problem is when the user returns from the detailed view to the search result table view, that the tableView becomes a regular table view and not a ResultTableView search. But the table is still filtered and only displays search results. Just tableView is no longer recognized as searchResultsTableView. So all my index calculations go wrong and the application crashes.

Any help is greatly appreciated.

Many thanks,

+3
source share
1 answer

- , TableView tableView. , , , - . searchDisplayController,

-(void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller

, , . , if tableView , . , , ( ) , tableView - searchResultTableView.

0

All Articles