I am trying to implement a search bar within one of the tabs in my UITabBarController, the tab is a UITableViewController within a UINavigationController...I am following an Apple tutorial - I have tried a lot of different options including answers mention here
Search bar gets cut off when using UISearchController with a UITabBarController inside a UINavigationController
I have tried setting the following property using
self.definesPresentationContext = true
or
self.tabBarController?.definesPresentationContext = true
Here is my code (from UITableViewController containing 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 an image of the searchbar:
And once I tap it: