Reputation: 2587
I have a tableview with a search bar. The search bar is provided by a UISearchController. When I add the search bar to the header view of the table, the first row of the table gets covered by the search bar.
How do I prevent the search bar from hiding the first row?
I have this snippet in viewDidLoad:
self.searchController = UISearchController(searchResultsController: nil)
self.searchController.searchResultsUpdater = self
self.searchController.searchBar.delegate = self
self.tableView.tableHeaderView = self.searchController.searchBar
self.searchController.dimsBackgroundDuringPresentation = false
self.searchController.searchBar.sizeToFit()
Upvotes: 9
Views: 2759
Reputation: 87
Found this issue to be a layout constraints issue. Resolved by dropping all of my constraints in the view containing my searchcontroller and adding back in individually until I found the offending constraint. Using Xcode 7.1
Upvotes: 0
Reputation: 3760
It seems that you have to explicitly set the scope button titles array if you don't have scope button titles.
self.searchController.searchBar.scopeButtonTitles = [NSArray array];
Upvotes: 9