Search code examples
objective-cioscocoa-touchanimationsearchbar

Toggle SearchBar in iOS


I have a TableView along with a search button at the bottom. I would like for the search button to cause a SearchBar to pop in at the top and be brought into focus. Otherwise, there should be no SearchBar showing.

It's easy enough to put a search bar above the TableView, but is there a way to hide/show it with animation?

Thanks.


Solution

  • Have you tried using the -[UITableView scrollRectToVisible:animated:] method? I think the UISearchBar view is usually just a header view on the table, so you should be able to ask the table view to scroll up to show the search bar.