Prior to iOS 13, when the search bar became the first responder, the below code displayed the scope bar with two scope bar buttons, which is the intended behavior.
With iOS 13, the search bar still functions correctly, however the scope bar is no longer being displayed. Apple's documentation for the UISearchBarDelegate seems to suggest using .setShowsScope(show:(bool), animated:(bool)) and .sizeToFit() for iOS 13. However, these function calls seemed not to have any effect. Looking for ideas to have the scope bar displayed as it did with iOS 12 and earlier.
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
//eventSearchBar is name of UISearchBar
//eventSearchBar.delegate has already been called out as self
//eventSearchBar is not owned by a UISearchController
self.navigationController?.setNavigationBarHidden(true, animated: true)
eventSearchBar.setShowsCancelButton(true, animated: true)
eventSearchBar.frame.size.height = 68
TitleView.frame.size.height = 132
eventSearchBar.scopeButtonTitles = ["Category", "Project"]
eventSearchBar.showsScopeBar = true
if eventSearchBar.text! == "" {
self.tableView.reloadData()
} else {
if eventSearchBar.selectedScopeButtonIndex == 0 {
self.loadSearchElements(self.refreshControl)
} else {
self.loadProjectSearchElements(self.refreshControl)
}
}
}
Problem solved. Issue is that the storyboard searchBar object has been updated for iOS 13. Solution was to remove the searchBar from the viewController in the storyboard and replace it with a new searchBar, dragged from the objects list. The old and new searchBar look identical, but the connection to their delegate properties is evidently different.