Table View Searching
A table view is a common way to present the results of a search performed through a search field (a UISearchBar; see Chapter 25). This is such a standard interface, in fact, that a class is provided, UISearchDisplayController, to mediate between the search field where the user enters a search term and the table view listing the results of the search. The UISearchDisplayController needs the following things:
- A search bar
-
A UISearchBar in the interface. This will be the UISearchDisplayController’s
searchBar
. - A view controller
-
The controller managing the view in the interface over which the search results are to appear. This will be the UISearchDisplayController’s
searchContentsController
. The UISearchDisplayController will harness this view controller’s view and present its table of results modally on top of it. - A table view
-
The table view in which the search results will be presented. This will be the UISearchDisplayController’s
searchResultsTableView
. It can already exist, or the UISearchDisplayController will create it. - A data source and delegate for the table view
-
The UISearchDisplayController’s
searchResultsDataSource
andsearchResultsDelegate
. They will control the data and structure of the search results table. They are commonly the same object, as for any table view; moreover, they are commonly the view controller. - A delegate
- An optional object adopting the UISearchDisplayDelegate protocol. It will be notified of events relating to the display ...
Get Programming iOS 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.