I have a UITableView with a searchbar on the top. I used UISearchDisplayController for implementing the same. And also it has a scope bar with two buttons. In default when I launch the app, the scope bar will be displayed. When I click the cancel button after the searching, the scopebar disappeared. So is there any way to keep the scopebar even after I pressed the Cancel button. I used the following code but its not working.
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
{
[searchBar setShowsScopeBar:YES];
return YES;
}
Thanks :)
I have also been battling with these kinds of
UISearchBarController
problems the last few days myself, and I have to say the best way to do anything unusual with a UISearchBar is to not use aUISearchDisplayController
at all!Just use a
UISearchBar
and theUISearchBarDelegate
methods and roll your own, then you can set everything all up to act exactly how you want.Here what I did in one recent project. - The scope bar always stays visible - I filter immediately as text is entered - I filter immediately if scope is changes - I hide the cancel button when it's not needed - I hide the keyboard when it's not needed
Works great :)