How do I close a UISearchDisplayController programmatically?

Raphael Caixeta picture Raphael Caixeta · Aug 23, 2010 · Viewed 7.3k times · Source

I want to close my UISearchDisplayController when the user clicks the "Search" button since I'm loading new data from the web. How do I close the controller programatically? I already have the proper method called, but don't know how to do it.

I thought that the below would work, but I'm wrong.

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    [self.searchDisplayController finalize];
}

Answer

Raphael Caixeta picture Raphael Caixeta · Aug 23, 2010
[self.searchDisplayController setActive:NO animated:YES];

Enjoy.