I am trying to implement a search bar on one of the tabs in my UITabBarController, the tab is the UITableViewController in the UINavigationController ... I am following an Apple tutorial. I tried many different options, including the answers here.
The search string is disabled when using the UISearchController with the UITabBarController inside the UINavigationController
I tried to set the following property using
self.definesPresentationContext = true
or
self.tabBarController?.definesPresentationContext = true
Here is my code (from a UITableViewController containing a UISearchBar):
/// Search controller to help us with filtering. var searchController: UISearchController! /// Secondary search results table view. var resultsTableController: SearchResultsTableController! override func viewDidLoad() { super.viewDidLoad() resultsTableController = SearchResultsTableController() resultsTableController.tableView.delegate = self searchController = UISearchController(searchResultsController: resultsTableController) searchController.searchResultsUpdater = self searchController.searchBar.sizeToFit() self.tableView.tableHeaderView = searchController.searchBar searchController.delegate = self searchController.dimsBackgroundDuringPresentation = true searchController.searchBar.delegate = self // so we can monitor text changes self.definesPresentationContext = true }
Here's the image of the search bar:

And as soon as I touch it: 
source share