我得到的錯誤:'ViewController'不符合協議'GMSAutoCompleteViewControllerDelegate'在下面的代碼。ViewController不符合協議GMSAutoCompleteViewControllerDelegate在Swift
class MapViewController: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate, GMSAutocompleteViewControllerDelegate {
...
@IBAction func autocompleteClicked(sender: AnyObject) {
let autoCompletController = GMSAutocompleteViewController()
autoCompletController.delegate = self
self.presentViewController(autoCompletController, animated: true, completion: nil)
}
//Handle user's selection
func viewController(viewController: GMSAutocompleteViewController!, didAutocompleteWithPlace place: GMSPlace!) {
//let placeName = place.name
//let placeAddress = place.formattedAddress
//let placeAttributions = place.attributions
let placeCoordinate = place.coordinate
mapView.camera = GMSCameraPosition(target: placeCoordinate, zoom: 15, bearing: 0, viewingAngle: 0)
}
func viewController(viewController: GMSAutocompleteViewController!, didAutocompleteWithError error: NSError!) {
// TODO: handle the error.
print("Error: ", error.description)
}
func wasCancelled(viewController: GMSAutocompleteViewController!) {
self.dismissViewControllerAnimated(true, completion: nil)
}
}
該修補程序是什麼?謝謝
你讀過[文檔](https://developers.google.com/maps/documentation/ ios-sdk/reference/protocol_g_m_s_autocomplete_view_controller_delegate-p),並確保你已經實現了所需的功能? – Laffen
是的,我從谷歌文檔得到這段代碼,並雙重檢查與我有所有必需的功能的API –
可能重複[ios Swift - API GoogleMaps - 不符合協議GSMAutocompleteViewControllerDelegate](http://stackoverflow.com/questions/ 34676576/ios-swift-api-google-map-not-conform-protocol-gsmautocompleteviewcontrollerd) – Laffen