GMSAutocompleteViewController

GMSAutocompleteViewController

我正在尝试在ios应用程序中使用API​​ GoogleMaps进行自动补全,但是我无法解决问题,我进行了搜索,但看来我是唯一拥有它的人。


  MyViewController不符合GSMAutocompleteViewControllerDelegate协议


class MyViewController: UIViewController {

    @IBAction func onLaunchClicked(sender: AnyObject) {
        let acController = GMSAutocompleteViewController()
        acController.delegate = self
        self.presentViewController(acController, animated: true, completion: nil)
    }
}

extension MyViewController: GMSAutocompleteViewControllerDelegate {

    func viewController(viewController: GMSAutocompleteViewController!, didAutocompleteWithPlace place: GMSPlace!) {
        // The user has selected a place.
        self.dismissViewControllerAnimated(true, completion: nil)
    }

    func viewController(viewController: GMSAutocompleteViewController!, didAutocompleteWithError error: NSError!) {
        self.dismissViewControllerAnimated(true, completion: nil)
    }

    func wasCancelled(viewController: GMSAutocompleteViewController!) {
        self.dismissViewControllerAnimated(true, completion: nil)
    }
}


似乎我没有所需的所有协议,但无法帮助我。

感谢您的帮助:)

最佳答案

尝试添加:

func viewController(viewController: GMSAutocompleteViewController!, didFailAutocompleteWithError error: NSError!) {

}

10-07 20:39