我已经像这样设置了 Google GMSAutocomplete:
private func setupAutocompleteWithTextFieldController() {
let kTextFieldTop: CGFloat = searchField.frame.origin.y
let kTextFieldHeight: CGFloat = 44.0
let kContentRectTop = kTextFieldTop + kTextFieldHeight
contentRect = CGRectMake(0, kContentRectTop, self.view.bounds.size.width, self.view.bounds.size.height - kTextFieldHeight)
searchField.autocorrectionType = .No
searchField.returnKeyType = .Done
searchField.clearButtonMode = .WhileEditing
searchField.addTarget(self, action: "searchFieldTextFieldEditingChanged:", forControlEvents: UIControlEvents.EditingChanged)
searchField.delegate = self
tableDataSource = GMSAutocompleteTableDataSource()
tableDataSource.delegate = self
resultsController = UITableViewController(style: UITableViewStyle.Plain)
resultsController.tableView.delegate = tableDataSource
resultsController.tableView.dataSource = tableDataSource
}
并且还实现了代表,UITextFieldDelegate
,GMSAutocompleteTableDataSourceDelegate
它工作得很好。但是,我想将搜索限制在地区、行政区域和国家。例如,我不希望它搜索“地点”。让
我知道有过滤器对象;但是,我如何将它应用到我的使用中?有任何想法吗?
filter = GMSAutocompleteFilter()
,filter.type = GMSPlacesAutocompleteTypeFilter.City