I am currently trying to add some search-functionality to my app, but there are some problems, when configuring this. I have a tab-based application with 3 tableviews and I want to add one searchbar for all tableviews. But it seems not that easy to set this up.
The first problem that occurs is that inside the Storyboard-Editor I only can add a separate searchbar to every tableview, but it is not possible to add searchbar to the tabBarController itself. So that the same searchbar is visible over all 3 tableviews.
The Second Problem then is, if I get this some how working, I have to setup a searchDisplayController with 3 different tableviews, but i can initialize a searchDisplayController with just one tableview.
What is the best approach of searching 3 different categories with one searchbar on an iPhone and are there any tutorials out there ? I was also looking at some other apps like facebook, and they are also searching just inside one tableview.
You can use three search display controllers as follows: have each vc on each tab implement a method (and declare it publicly) like this:
Each of those should implement this method:
You might need to make sure all your other tab vcs are loaded (if you launch the app, visit just one tab and try this, the other vcs might not be ready. To do that, just insert this line in the loop to force the view to load:
(void)[otherVC view];(note – this answer presumes ARC)