I added a search bar and a search controller (assuming I'm adding to the storyboard, since they don't have a SearchController object to drag and drop).
My problem is how to set properties on this SearchController now? self.searchController does not work, and Xcode says it is automatically added when I add a UISearchBar to the view. What am I doing wrong? The reason I need access is because I can set up a search results table, for example:
UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain]; searchResultsController.tableView.dataSource = self; searchResultsController.tableView.delegate = self; self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController]; self.searchController.searchResultsUpdater = self;
I noticed an example here: https://github.com/dempseyatgithub/Sample-UISearchController
Which says it uses storyboards, doesn't actually use storyboards to add to the UISearchController, but uses code to isolate and initialize and set the frame.
James source share