UISearchBar Archives

How to add a Search Display Controller to a UITableView (in code)

We’ve recently discussed how to deal with a Search Bar and Search Display Controller using Interface Builder. You can however do this in code too. This can be useful if you don’t want to make all the relevant connections in every Storyboard. This example assumes you have a Table View (self.tableView) to which you’d like […]

How to hide (and show) the UISearchBar in a UITableView

If you add a UISearchBar to your table view (see previous article) it’s just sitting there by default. Chances are you’d like to hide it when your table view first loads. You can do this by adding the following code to your viewWillAppear method: – (void)viewWillAppear:(BOOL)animated { // scroll the search bar off-screen CGRect newBounds […]

How to create a searchable UITableView

The ingredients for a search function in a UITableView are more involved than just displaying a simple search field. First we need the standard UITableView. Next we need a UISearchBar which can be added to the top of the table view. But displaying the actual search results is something called the UISearchDisplayController. This process isn’t […]