Change the searchDisplayController table view style to grouped?

Noam picture Noam · Sep 26, 2010 · Viewed 10.5k times · Source

I have a searchDisplayController that searches a UITableView.

After entering the search terms, I can see another UITableView that contains the search results. However, I want this UITableView to be GROUPED, not PLAIN (like it is by default).

How do I do this?

Answer

Steve Dekorte picture Steve Dekorte · Mar 21, 2012

This worked for me (iOS 5.0):

self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
[self.searchController setValue:[NSNumber numberWithInt:UITableViewStyleGrouped]
        forKey:@"_searchResultsTableViewStyle"];