【问题标题】:GMSAutocompleteResultsViewControllerDelegate conforming to protocol SwiftGMSAutocompleteResultsViewControllerDelegate 符合 Swift 协议
【发布时间】:2016-01-31 01:17:54
【问题描述】:

我正在尝试使用 Google Maps SDK for IOS 中的一些示例代码。下面的代码给了我一条错误消息:类型ViewController 不符合协议GMSAutocompleteResultsViewControllerDelegate。请参阅下面的代码。有谁知道什么不符合。

extension ViewController: GMSAutocompleteResultsViewControllerDelegate {
    func resultsController(resultsController: GMSAutocompleteResultsViewController!,
        didAutocompleteWithPlace place: GMSPlace!) {
            searchController?.active = false
            // Do something with the selected place.
            print("Place name: ", place.name)
            print("Place address: ", place.formattedAddress)
            print("Place attributions: ", place.attributions)
    }

    func resultsController(resultsController: GMSAutocompleteResultsViewController!,
        didAutocompleteWithError error: NSError!){
            // TODO: handle the error.
            print("Error: ", error.description)
    }
}

【问题讨论】:

    标签: swift protocols google-places-api google-maps-sdk-ios


    【解决方案1】:

    很遗憾,网站上的示例代码不正确。协议方法其实叫didFailAutocompleteWithError,而不是didAutocompleteWithError。

    【讨论】:

      猜你喜欢
      • 2021-02-04
      • 2015-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 2018-01-23
      • 1970-01-01
      相关资源
      最近更新 更多