Ich versuche, die erste Ansicht ist die aktuelle Position des Benutzers auf der Karte, aber ich stehe immer App auf der Leitung 22. Vielen Dank an jeden, der mir helfen kann oder vielleicht eine andere Möglichkeit, dies zu tunGoogleMaps IOS SDK: viewMap.myLocationEnabled = true. funktioniert nicht
viewMap.myLocationEnabled = true
wirft diesen Fehler:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setMyLocationEnabled:]: unrecognized selector sent to instance 0x14c5bde10'
für den folgenden Code:
import UIKit
import GoogleMaps
class WhereViewController: UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var viewMap: GMSMapView!
var locationManager = CLLocationManager()
var didFindMyLocation = false
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
viewMap.addObserver(self, forKeyPath: "myLocation", options: NSKeyValueObservingOptions.New, context: nil)
print("despues de observer")
viewMap.myLocationEnabled = true // Line 22
}
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
if status == CLAuthorizationStatus.AuthorizedWhenInUse{
viewMap.myLocationEnabled = true
print("sali de locationManager")
}
}
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if !didFindMyLocation{
print("dentro de observer false")
let myLocation: CLLocation = change![NSKeyValueChangeNewKey] as! CLLocation
viewMap.camera = GMSCameraPosition.cameraWithTarget(myLocation.coordinate, zoom: 10.0)
viewMap.settings.myLocationButton = true
didFindMyLocation = true
}
print("dentro de observer false")
}
}
Ich komme zu mir nach Hause und ich werde es versuchen. Vielen Dank – user3324336
Das funktioniert! : D thx – user3324336
Froh, geholfen zu haben! Könnten Sie bitte die Antwort als akzeptiert markieren? Danke! – stakri