info.plist Datei:derzeit keine Orte, um zu sehen: [CLLocation]
<key>NSLocationWhenInUseUsageDescription</key>
<string>This project would like to know your location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>location when app is in background</string>
Wie oben gezeigt, hat die Schlüssel/Wert-Paare für die info.plist
hinzugefügtDas Problem, das ich mit Blick auf bin ist Als ich die App das erste Mal gestartet habe, wurde ich zur Autorisierung aufgefordert, aber bei nachfolgenden Läufen wurde das Popup nicht angezeigt.
Sekunden, ich versuche, die Standorte von
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
mit dem print(location)
aber nichts gedruckt zu drucken.
in den Debug-Optionen i Lage als „Stadt Fahrradfahrt“ eingestellt haben
Der Code i bin mit wie folgt.
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate , CLLocationManagerDelegate {
@IBOutlet var map: MKMapView!
//use the locManager to get the users location
var locManager = CLLocationManager()
override func viewDidLoad() {
locManager.delegate = self
locManager.desiredAccuracy = kCLLocationAccuracyBest
locManager.requestWhenInUseAuthorization()
super.viewDidLoad()
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print(locations)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
fand ich eine Lösung für den Standort prompt. Ich habe den Simulator zurückgesetzt und es hat funktioniert. Gibt es eine Möglichkeit, es zu beheben, ohne den Simulator zurückzusetzen? Das Problem bleibt bestehen..was ich meine ist, dass, sobald ich es zurückgesetzt habe, es mich einmal und nie wieder bis zum nächsten Reset anfordert. Die Standorte werden jedoch nicht gedruckt ... – baconSoda
Was ist mit dem Aufruf von 'startUpdatingLocation()' ...? –
@MartinR Ja, du hast recht, ich musste 'startUpdatingLocation()' danke :) – baconSoda