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函數永遠不會被調用。它甚至不打印任何內容來記錄。