Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I close a UISearchDisplayController programmatically?

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]; } 
like image 782
Raphael Caixeta Avatar asked Aug 23 '10 14:08

Raphael Caixeta


2 Answers

[self.searchDisplayController setActive:NO animated:YES]; 

Enjoy.

like image 98
Raphael Caixeta Avatar answered Oct 22 '22 05:10

Raphael Caixeta


You need to make sure you set active to false on main thread:

dispatch_async(dispatch_get_main_queue(), ^{     [self.searchDisplayController setActive:NO animated:YES]; }); 
like image 28
LiorR Avatar answered Oct 22 '22 04:10

LiorR