【问题标题】:Google autocomplete Swift UITextField谷歌自动完成 Swift UITextField
【发布时间】:2018-01-08 06:25:25
【问题描述】:

有没有人遇到过有关如何在 UITextField 上添加 GoogleAutoComplete 的任何资源。我只看过有关如何将搜索栏添加到导航控制器或过时且充满错误的教程。我想将它添加到 UITextField。尚未在 GitHub 上找到任何适用于 Swift 4 的有效解决方案。

【问题讨论】:

    标签: ios swift google-places-api


    【解决方案1】:

    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
        }
    }
    

    【讨论】:

    • 我在 filter.type = .establishment 上收到预期的声明错误
    猜你喜欢
    • 1970-01-01
    • 2017-08-16
    • 2016-01-31
    • 1970-01-01
    • 1970-01-01
    • 2011-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多