Search code examples
iphoneiosuikituisearchbaruisearchdisplaycontroller

Display searchResultsTableView when UISearchBar is activated initially


I am currently using a searchDisplayController with a UISearchBar to try to implement autocomplete functionality in my iPhone app.

However, when the user first presses the UISearchBar, the search controller displays a dim UIView to focus on the search bar.

Instead, I want the actual searchResultsTableview (including past queries, autocomplete suggestions, etc) to be shown initially.

Any idea on what method to override/implement to get this to work? Thanks!


Solution

  • I've never seen the point in using UISearchBarController (or UITableViewController) because they throw in so much actions with it I would simply make the UISearchBar outlet and declare in your interface, that way you can put your custom methods in.

    So here you would have been populating a search array with every search, so when search bar is pressed (there's a delegate method something like (UISearchBar*) didBeginEditing;) you would display your custom list, and when they press one, set searchBar.text = nil (in case they entered something) and then searchBar.text = [cell objectAtIndex:indexPath.row].stringValue (Psuedo code! have not tried!) Just remember to swap your arrays depending on what is going on