我正在跟踪适用于iOS的Google MAP SDK Tutorial,几乎一切都很好,但是此功能
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject, change: [String : AnyObject], context: UnsafeMutablePointer<Void>) {
if !didFindMyLocation {
let myLocation: CLLocation = change[NSKeyValueChangeNewKey] as! CLLocation
viewMap.camera = GMSCameraPosition.cameraWithTarget(myLocation.coordinate, zoom: 10.0)
viewMap.settings.myLocationButton = true
didFindMyLocation = true
}
}
“方法不会覆盖其 super class 中的任何方法”
Xcode 7
迅捷2
Google Map iOS SDK
任何的想法?
谢谢
最佳答案
你可以试试这个吗?更新了最新版本的Swift的代码。看起来该示例基于旧版本的Swift。
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if !didFindMyLocation {
let myLocation: CLLocation = change![NSKeyValueChangeNewKey] as! CLLocation
viewMap.camera = GMSCameraPosition.cameraWithTarget(myLocation.coordinate, zoom: 10.0)
viewMap.settings.myLocationButton = true
didFindMyLocation = true
}
}