I have two view controllers each one contains UISearchController and a UITableView. The Code in viewDidLoad is:
SearchResultsTableViewController *searchResultController = [[SearchResultsTableViewController alloc]initWithNibName:@"SearchResultsTableViewController" bundle:nil];
UINavigationController *navSearchResultsController = [[UINavigationController alloc] initWithRootViewController:searchResultController];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:navSearchResultsController];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = YES;
[self.searchController.searchBar sizeToFit];
self.searchController.searchBar.delegate = self;
self.searchController.delegate = self;
self.tableView.tableHeaderView = self.searchController.searchBar;
self.tableView.userInteractionEnabled = YES;
The first view controller is the rootViewController, which works perfectly without any problem. The second view controller is being pushed via the navigation controller based on segment selection.
[self.navigationController pushViewController:self.vc];
There is only one problem with the second view controller. When I tap on the searchBar, it animates to the top and goes underneath the navigation bar while the first one animates in its spot and does not go up.
Can anyone tell me how to disable this animation?
I want to keep the searchBar in its same place while searching. It's exactly the same implementation for both view controllers. Why does each one act differently?
Thanks,