MKMapView
デリゲート メソッドを呼び出すことができませんdidUpdateUserLocation
。
私がこれまでにやったこと:
MapKit.framwork
プロジェクトにフレームワークを追加import MapKit
フレームワークをView Controllerに1行ずつインポートするplistファイルにキーを追加
<key>NSLocationAlwaysUsageDescription</key> <true/>
ビューコントローラーのコード
場所が更新されているかどうかを確認するデリゲートdidUpdateUserLocation
メソッドを追加しましたが、呼び出されませんでした。
// MARK: - MapView delegate methods
func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool) {
// Calling...
}
func mapView(mapView: MKMapView!, didUpdateUserLocation userLocation: MKUserLocation!) {
// Not getting called
}
// MARK: - View lifeCycle methods
override func viewDidLoad() {
super.viewDidLoad()
var locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
self.mapView.delegate = self
self.mapView.showsUserLocation = true
self.mapView.pitchEnabled = true
self.mapView.showsBuildings = true
}
シミュレーターを使用し、シミュレーターのカスタムの場所を変更して、それが呼び出されているかどうかを確認しましたか? メソッドregionDidChangeAnimated
は完全に呼び出されます! .
同じことがiOS7でも機能します。Swift マップの位置更新のために残っている追加の作業は何ですか?
編集: Plistキー
また、許可の警告は求められません。