1

我正在将GMSAutocompleteResultsViewController用于谷歌自动完成搜索位置。当我用它搜索时,它显示的结果非常有限。它没有显示所有结果。此外,当它在 android 中使用时,它显示了许多结果。请让我知道我错过了什么。

 override func viewDidLoad() {
        super.viewDidLoad()

        resultsViewController = GMSAutocompleteResultsViewController()
        resultsViewController?.delegate = self

        searchController = UISearchController(searchResultsController: resultsViewController)
        searchController?.searchResultsUpdater = resultsViewController

        // Put the search bar in the navigation bar.
        searchController?.searchBar.sizeToFit()
        navigationItem.titleView = searchController?.searchBar

        // When UISearchController presents the results view, present it in
        // this view controller, not one further up the chain.
        definesPresentationContext = true
        // Prevent the navigation bar from being hidden when searching.
        searchController?.hidesNavigationBarDuringPresentation = false
    }
4

1 回答 1

2

我自己找到了答案。适用于 iOS 的 Google API 仅提供 5 个搜索结果,而对于 Android,它提供更多结果。您可以参考以下链接

https://developers.google.com/places/web-service/autocomplete#place_autocomplete_responses

于 2018-12-12T06:35:13.363 回答