locationManager.startUpdatingLocationWithCompletionHandler не получает завершение - PullRequest
0 голосов
/ 01 ноября 2018

Я пытаюсь интегрировать MapKit в свое приложение IOS,

Я использую LocationManager.

это мой код:

   func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
    if status != CLAuthorizationStatus.notDetermined || status != CLAuthorizationStatus.denied || status != CLAuthorizationStatus.restricted {
        getLocation()
    }
}

func getLocation(){
    locationManager.startUpdatingLocationWithCompletionHandler { (latitude, longitude, status, verboseMessage, error) -> () in
        self.displayLocation(location: CLLocation(latitude: latitude, longitude: longitude))

    }



}

func displayLocation(location:CLLocation) {

    map.setRegion(MKCoordinateRegion(center: CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)), animated: true)

    //set pin
    let locationPinCOord = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
    let annotaion = MKPointAnnotation()
    annotaion.coordinate = locationPinCOord

    map.addAnnotation(annotaion)
    map.showAnnotations([annotaion], animated: true)
    locationManager.reverseGeocodeLocationWithCoordinates(location) { (reverseGeocodeInfo, placemark, error) in
        print(reverseGeocodeInfo)
    }

}

но по какой-то причине функция displayLocation никогда не вызывается.

...