0
我在plist中加入NSLocationWhenInUseUsageDescription并将其设置为YES,这里是我的代码:当前位置9
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last
let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
self.mapView.setRegion(region, animated: true)
print(location)
print(center)
}
但它仍然无法正常工作。它只是没有显示任何东西。 它看起来像locationManager函数永远不会被调用。它甚至不打印任何内容来记录。