I have created a Table View Controller that I am happy with, and now want to add a search view to it. I have added the 'Search bar and search display controller' using the storyboard, and tried to follow many tutorials for adding a search bar, but it seems that all of them are now deprecated. I do not want to add the search programatically, as I want it to be in quite a specific position on the storyboard, not at the top of the screen.
The issue is that the updateSearchResultsForSearchController is not being called at all. I've put a break in this function to confirm this.
I have the following code:
class ViewItemTableViewController: UITableViewController, UIPickerViewDelegate, UIPickerViewDataSource, UISearchBarDelegate, UISearchDisplayDelegate {
// lots of other unrelated things
@IBOutlet weak var searchBar: UISearchBar!
func updateSearchResultsForSearchController(searchController: UISearchController)
{
listItems = allItems.retrieveItemById(1)
self.tableView.reloadData()
}
}
How do I correctly configure the search bar so that this function is called on change of the search value?