Ich hatte MapView auf Benutzer Standort am Anfang meines Projekts, aber jetzt wird es nicht auf den Benutzer beim Start vergrößern. Irgendeine Idee, wie man das repariert? i der Code verwenden:Swift User Location Problem
In Klasse
class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate
var Locationmanager = CLLocationManager()
In viewDidLoad
self.Locationmanager.delegate = self
self.Locationmanager.desiredAccuracy = kCLLocationAccuracyBest
self.Locationmanager.requestWhenInUseAuthorization()
self.Locationmanager.startUpdatingLocation()
self.Mapview.showsUserLocation = true
Mapview.setCenterCoordinate(Mapview.userLocation.coordinate, animated: true)
In Funktion
func locationManager(manager: CLLocationManager, didUpdateLocations locations:[MKUserLocation]) {
let latitude = Locationmanager.location?.coordinate.latitude
let longitude = Locationmanager.location?.coordinate.longitude
let center = CLLocationCoordinate2D (latitude: latitude!, longitude: longitude!)
let region = MKCoordinateRegion (center: center, span: MKCoordinateSpan (latitudeDelta: 0.02, longitudeDelta: 0.02))
self.Mapview.setRegion(region, animated: true)
self.Locationmanager.stopUpdatingLocation()
Und in info.plist
NSLocationWhenInUseUsageDescription
Nun, ich muss um Erlaubnis fragen für den Benutzer Standort .. wird versuchen und entfernen und sehen, was passiert – Adam
Immer noch nicht den Zoom auf Benutzerstandort beim Start .. – Adam
Nö nicht gelöst .. andere Code zum Finden des Standortes des Benutzers? – Adam