Overview
GMSAutocompleteTableDataSource provides an interface for providing place autocomplete predictions to populate a UITableView by implementing the UITableViewDataSource and UITableViewDelegate protocols.
GMSAutocompleteTableDataSource is designed to be used as the data source for a UISearchDisplayController.
- Note:
- UISearchDisplayController has been deprecated since iOS 8. It is now recommended to use UISearchController with
GMSAutocompleteResultsViewController
to display autocomplete results using the iOS search UI.
Set an instance of GMSAutocompleteTableDataSource as the searchResultsDataSource and searchResultsDelegate properties of UISearchDisplayController. In your implementation of shouldReloadTableForSearchString, call sourceTextHasChanged with the current search string.
Use the GMSAutocompleteTableDataSourceDelegate
delegate protocol to be notified when a place is selected from the list. Because autocomplete predictions load asynchronously, it is necessary to implement didUpdateAutocompletePredictions and call reloadData on the UISearchDisplayController's table view.
Public Member Functions | |
(instancetype) | - init |
Initializes a data source. | |
(void) | - sourceTextHasChanged: |
Notify the data source that the source text to autocomplete has changed. | |
(void) | - clearResults |
Clear all predictions. | |
Properties | |
IBOutlet id < GMSAutocompleteTableDataSourceDelegate > | delegate |
Delegate to be notified when a place is selected or picking is cancelled. | |
GMSAutocompleteFilter * | autocompleteFilter |
Filter to apply to autocomplete suggestions (can be nil). | |
UIColor * | tableCellBackgroundColor |
The background color of table cells. | |
UIColor * | tableCellSeparatorColor |
The color of the separator line between table cells. | |
UIColor * | primaryTextColor |
The color of result name text in autocomplete results. | |
UIColor * | primaryTextHighlightColor |
The color used to highlight matching text in autocomplete results. | |
UIColor * | secondaryTextColor |
The color of the second row of text in autocomplete results. | |
UIColor * | tintColor |
The tint color applied to controls in the Autocomplete view. | |
GMSPlaceField | placeFields |
The GMSPlaceField for specifying explicit place details to be requested. | |
NSArray< GMSPlaceProperty > * | placeProperties |
The GMSPlaceProperty for specifying explicit place details to be requested. |
Member Function Documentation
- (instancetype) init |
Initializes a data source.
- (void) sourceTextHasChanged: | (nullable NSString *) | text |
Notify the data source that the source text to autocomplete has changed.
This method should only be called from the main thread. Calling this method from another thread will result in undefined behavior. Calls to GMSAutocompleteTableDataSourceDelegate
methods will also be called on the main thread.
This method is non-blocking.
- Parameters:
-
text The partial text to autocomplete.
- (void) clearResults |
Clear all predictions.
- Note:
- This will call the two delegate methods below:
didUpdateAutocompletePredictionsForResultsController:
didRequestAutocompletePredictionsForResultsController:
The implementation of this method is guaranteed to call these synchronously and in-order.
Property Documentation
- (IBOutlet id<GMSAutocompleteTableDataSourceDelegate>) delegate [read, write, assign] |
Delegate to be notified when a place is selected or picking is cancelled.
- (GMSAutocompleteFilter*) autocompleteFilter [read, write, assign] |
Filter to apply to autocomplete suggestions (can be nil).
- (UIColor*) tableCellBackgroundColor [read, write, assign] |
The background color of table cells.
- (UIColor*) tableCellSeparatorColor [read, write, assign] |
The color of the separator line between table cells.
- (UIColor*) primaryTextColor [read, write, assign] |
The color of result name text in autocomplete results.
- (UIColor*) primaryTextHighlightColor [read, write, assign] |
The color used to highlight matching text in autocomplete results.
- (UIColor*) secondaryTextColor [read, write, assign] |
The color of the second row of text in autocomplete results.
- (UIColor*) tintColor [read, write, assign] |
The tint color applied to controls in the Autocomplete view.
- (GMSPlaceField) placeFields [read, write, assign] |
The GMSPlaceField
for specifying explicit place details to be requested.
Default returns all available fields.
- (NSArray<GMSPlaceProperty>*) placeProperties [read, write, assign] |
The GMSPlaceProperty
for specifying explicit place details to be requested.
Default returns all available properties.