I have the UISearchDisplayController page view as follows (original state)
After clicking on the searchbar and typing some search term, I get a list of results in the table
After clicking on an entry in the table, a new viewController is displayed on top of the stack
My intention is that on the click of the cancel button (on top left), the root view will display the original state of the searchDisplay controller
This is what I have tried
In my cancel method (triggered when I click on the top left hand cancel button)
- (void)cancel
{
[self dismissViewControllerAnimated:YES completion:NULL];
[self searchBarCancelButtonClicked:self.searchDisplayController.searchBar];
}
And in the searchbar delegate method I did this
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
self.searchBar.showsCancelButton = NO;
[self.searchBar resignFirstResponder];
self.searchBar.text = @"";
searchDisplayController.searchResultsTableView.hidden = YES;
[self searchDisplayControllerWillEndSearch:self.searchDisplayController];
}
All I manage to achieve after clicking on the cancel button is this
The original tableview seems to be missing (appears only if I click on the page)
How can I modify my methods to revert the search to its' original state?
Try [searchDisplayController setActive:NO animated:NO]
This should hide the search table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With