I'm using a UISearchController inside ma UIViewcontroller
that contains a UITableView
, I do this in viewDidLoad
:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.delegate = self;
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.definesPresentationContext = NO;
when I push a button in the navbar i do this:
self.tableView.contentOffset = CGPointMake(0, 0 - self.tableView.contentInset.top);
self.tableView.tableHeaderView = self.searchController.searchBar;
[self.searchController.searchBar becomeFirstResponder];
all works fine, but when I push a UIViewController
from a row in the UITableView
results the UISearchBar
stay there and display also on the content of the other view, how can i dismiss when I push a view and present when I go back to see the result of the UITableView
?
thanks
EDIT:
this is the code of the method didSelectRowAtIndexPath
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
DetailListController *detailList = [[DetailListController alloc] init];
[self.navigationController pushViewController:detailList animated:YES];
}
Put this code in your viewDidLoad
:
self.definesPresentationContext = YES;