I am using UISearchController
and when I click on the searchbar , I get animation as if the searchbar is going to the navigation bar of the presented searchcontroller with fading animation but it disappears and the keyboard presented is staying there.
In viewcontroller.m, viewdidload method, relevant part:
UIView *searchView = [[UIView alloc]initWithFrame:CGRectZero];
searchResultsViewController =[[SearchResultsViewController alloc]initWithNibName:@"SearchResultsViewController" bundle:nil];
self.searchController =[[UISearchController alloc]initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater=self;
self.searchController.dimsBackgroundDuringPresentation = NO;
searchView = self.searchController.searchBar;
self.definesPresentationContext = YES;
self.searchController.searchBar.delegate=self;
searchView.frame =CGRectMake(0, 50, [[UIScreen mainScreen]bounds].size.width, 40);
[self.view addSubview:searchView];
The SearchResultsViewController is a UIViewController
with filtered Array which gets its value from -(void)updateSearchResultsForSearchController:(UISearchController *)searchController
method in ViewController
As the search bar was disappearing, I tried to put the searchbar as a header for the TableView in ViewController, it is working normally . but when I just put the searchbar view as custom created view instead of table header, it is disappearing.
Any insight would be appreciated. Thanks
Try with these two settings:
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.definesPresentationContext = NO;