Cannot set searchBar as firstResponder

I noticed this issue too. What seems to happen is the call to becomeFirstResponder is done when the searchController is still ‘loading’. If you comment out becomeFirstResponder you notice that there is no difference. So we need a way to call becomeFirstResponder after the searchController is ‘done’ loading. When I looked at various delegate methods … Read more

UISearchController persisting after segue

You can hide the searchController manually by setting the active property to false in prepareForSegue. Add the below code in prepareForSegue() searchController.active = false Alternatively, you should add the following line in viewDidLoad() to get the default behaviour definesPresentationContext = true From the documentation for definesPresentationContext A Boolean value that indicates whether this view controller’s … Read more

iOS 13 UIBarButtonItem not clickable and overlapping UINavigationBars when using UISearchController

The view debugger reveals what’s going on with this bug. The contents of the navigation bar are being copied. Here’s what the navigation bar looks like before you show the search: And here’s what it looks like afterwards: The two replicant views and the extra UILabel are the problem. I don’t know what they’re doing … Read more

How to implement UISearchController in UITableView – Swift

Yes, the way search works has been radically changed for what I consider to be a better system. The new system is much better and straight to the point for most simple implementations. Using it is pretty straightforward. First, make your class comply with the UISearchResultsUpdating protocol. class MyTableViewController: UITableViewController, UISearchResultsUpdating {} Add it the … Read more

UISearchBar presented by UISearchController in table header view animates too far when active

Old question but I was able to solve this issue by setting self.extendedLayoutIncludesOpaqueBars = YES; on my view controller. I think is issue is caused by having an opaque navigation bar but setting hidesNavigationBarDuringPresentation to NO on your search controller, causing the search bar to incorrectly position itself when focused.