Google Map SDK 和 iOS,observeValueForKeyPath 问题
Google Map SDK and iOS, observeValueForKeyPath issues
我正在为 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
}
}
"Method does not override any method from its superclass"
Xcode 7
Swift 2
Google地图iOSSDK
有什么想法吗?
谢谢
你能试试这个吗?更新了最新版本 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
}
}
我正在为 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
}
}
"Method does not override any method from its superclass"
Xcode 7 Swift 2 Google地图iOSSDK
有什么想法吗?
谢谢
你能试试这个吗?更新了最新版本 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
}
}