I've recently added a UISearchController to my table view and I'm experiencing an animation issue. When the search bar is tapped and becomes active, the table view jumps up to meet the search controller's new (active) position. The problem with this is that the search controller animates to this new position but the table view doesn't so it's quite jarring. Here is a video of the issue.
The top constraint on the table view is set to the view controller's safe area. Below is the code I have written for configuring the search controller:
- (void)configureSearchController {
UISearchController *searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
searchController.searchResultsUpdater = self;
searchController.obscuresBackgroundDuringPresentation = NO;
searchController.searchBar.placeholder = @"Search for any cryptocurrency";
self.searchController = searchController;
if (@available(iOS 11.0, *)) {
self.navigationItem.searchController = searchController;
} else {
self.navigationItem.titleView = searchController.searchBar;
}
self.definesPresentationContext = YES;
}
Does anyone have any suggestions as to how I can make the transition smooth? Ideally I would like the table view to move up at the same rate as the search controller as this is the default behaviour throughout iOS.