ios Swift - API GoogleMaps - 不符合协议 GSMAutocompleteViewControllerDelegate

问题描述 投票:0回答:1

我正在尝试在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)
    }
}

我似乎没有所需的所有协议,但无法掌握它。

ios swift google-maps autocomplete protocols
1个回答
0
投票

尝试添加:

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

}
© www.soinside.com 2019 - 2024. All rights reserved.