是否有人遇到过有关如何在UITextField上添加GoogleAutoComplete的任何资源。我只看过有关如何将搜索栏添加到导航控制器或过时且充满错误的教程。我想将它添加到UITextField。 Haven没有在GitHub上找到Swift 4的任何工作解决方案。
答案 0 :(得分:0)
import GooglePlaces
到您的文件中,然后将UITextField
文本传递给此方法: -
let placeClient = GMSPlacesClient.init()
let filter = GMSAutocompleteFilter()
filter.type = .establishment
filter.country = "in" //in for India (Only India address will be searched)
placeClient.autocompleteQuery("Pass your text here", bounds: nil, filter: filter) { (results, error) in
if let err = error {
print("Autocomplete error \(err)")
return
}
if let results = results {
// show result in your table view
}
}