My ViewController is a custom UIViewController <UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate, UISearchDisplayDelegate>. I have set up the UISearchBar to display a scope bar.
I instantiate the view controller once and then show the same view on demand via [self presentModalViewController:mySearchController fromView:self.view];
Now, when I configure the view controller to be displayed as a form sheet, the scope bar appears only the first time the view is shown. The next time the scope bar is not displayed.
Displaying the view as a page sheet works fine. However in this case I observe that the first time the scope bar is already in place, while thereafter it is animated into the search bar as soon as it becomes the first responder.
I fiddled around with the view and controller settings in the inspector without any success.
What is causing this behavior?
How can I make the scope bar appear in the form sheet the next time I am showing the view?
Is there a way to prevent the UISearchBar from going into a different state when its view is hidden/redisplayed?
Set the scope bar titles in search
delegatefor begin editing and make itnilwhen the search ends. And add theshowScopeBarmethod right after this method. Try and check if that helps.For eg:-
And in
didEndEditing,In addition to this, whenever you want to display the scopebar you can use the above lines to show and hide it.