【发布时间】:2018-01-08 06:25:25
【问题描述】:
有没有人遇到过有关如何在 UITextField 上添加 GoogleAutoComplete 的任何资源。我只看过有关如何将搜索栏添加到导航控制器或过时且充满错误的教程。我想将它添加到 UITextField。尚未在 GitHub 上找到任何适用于 Swift 4 的有效解决方案。
【问题讨论】:
标签: ios swift google-places-api
有没有人遇到过有关如何在 UITextField 上添加 GoogleAutoComplete 的任何资源。我只看过有关如何将搜索栏添加到导航控制器或过时且充满错误的教程。我想将它添加到 UITextField。尚未在 GitHub 上找到任何适用于 Swift 4 的有效解决方案。
【问题讨论】:
标签: ios swift google-places-api
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
}
}
【讨论】: