The UISearchDisplayController is very handy and implementing search is pretty straightforward.
However, I bump into problem when, in my app, I want to display search result with empty search string but selected scope button.
It seems like it's a must to enter some search string in order to get the search result table being initialized and displayed.
Is there any ways to display search result immediately after user has picked a scope but not entered search word yet?
Thanks Bill
when you tap a new scope button the selectedScopeButtonIndex fires:
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption;
you could capture the title fire off your search here using:
[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]
Won't work on the initial scope index, but you could just fire off your search initially based on the last used selectedScopeButtonIndex
I was after the same thing and just found something in the Apple developer forums: The UISearchDisplayController
is implemented in a way that the results table won't be shown until some text is entered. There's also a bug report about this: ID# 8839635.
I worked around it by putting a segmented control underneath the search bar, imitating the scope bar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With