MKMapView (iOS) のメモ

以下のページに詳しく説明してあるので、その通りにやれば問題ないはず。

About Location Services and Maps
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/Introduction/Introduction.html

Getting the User’s Location
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html#//apple_ref/doc/uid/TP40009497-CH2-SW1

MapKit.Framework はMapKitViewを追加したら勝手に追加されてた気がしますが、またはProject>Capabilitiesからも追加できます。
CoreLocation.Framework はProject>Build Phases から追加

 

ただし、現在位置に移動しようとしたら以下のエラーがでるかもしれません。

Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

そのときは Info.plist に以下のエントリを追加します。

   <key>NSLocationAlwaysUsageDescription</key>

    <string>Please allow this app to access your location.</string>

    <key>NSLocationWhenInUseUsageDescription</key>

    <string>Please allow this app to access your location.</string>

タグ:

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください