I am creating a UISearchViewController and I want to put a UISearchBar in the navigation element of the navigation controller. Here is how I did it without any results:
self.searchBar = [UISearchBar new]; self.searchBar.showsScopeBar = YES; self.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"]; self.searchBar.delegate = self; self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self]; self.searchController.delegate = self; self.searchController.searchResultsDataSource = self; self.searchController.searchResultsDelegate = self; self.searchController.displaysSearchBarInNavigationBar = YES;
I also tried:
self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleMinimal; self.searchDisplayController.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"]; self.searchDisplayController.searchBar.showsScopeBar = YES;
Did I miss something or did something wrong?
Edit: This and this is exactly what I'm aiming for.
source share