OGeek|极客世界-中国程序员成长平台

标题: ios - 谷歌自动完成 Swift UITextField [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:34
标题: ios - 谷歌自动完成 Swift UITextField

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



Best Answer-推荐答案


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("ass 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
    }
}

关于ios - 谷歌自动完成 Swift UITextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48145221/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4