MKMapViewDelegate mapView:didUpdateUserLocation: メソッドは、デバイス設定ですべての場所のアクセス許可が指定されている場合でも、5.0 シミュレーターでの実行時に呼び出されません。
4.3では問題なく動作しています。
何か案は?
MKMapViewDelegate mapView:didUpdateUserLocation: メソッドは、デバイス設定ですべての場所のアクセス許可が指定されている場合でも、5.0 シミュレーターでの実行時に呼び出されません。
4.3では問題なく動作しています。
何か案は?
「setUserTrackingMode:animated:」と「userTrackingMode」を確認してください。どちらも iOS5 の新機能です。同様の問題があり、 setUserTrackingMode 関数で MKUserTrackingModeFollow を設定して修正しました。デフォルトのトラッキング モードは MKUserTrackingModeNone であり、mapView:didUpdateUserLocation を 1 回だけ呼び出すと思います。
問題が mapView:didUpdateUserLocation が呼び出されないことである場合は、新しい xcode のオプションを見てください。コンソール出力のすぐ下に、場所をシミュレートできる ipad の gps アイコンのようなアイコンがあります。
私はそれが古いスレッドであることを知っています。とにかく答えます。他の人にも役立つかもしれません。
iOS 6 でも同様の問題がありました。mapview デリゲートを self に設定することで解決できました。
このような:
[mapView setDelegate:self];
ViewController.h が次の行に沿って MKMapViewDelegate を持っていることを確認してください。
@interface ViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate>
ARCにリファクタリングした後も同じことがわかりました。
まず、viewDidLoad に次のコードがありました。
CLLocationManager *lm =[[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
[lm startUpdatingLocation];
ヘッダーファイルで次のことを行いました
@interface ViewController : UIViewController <CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
}
@property(nonatomic, strong)CLLocationManager *locationManager;
と
@synthesize locationManager;
viewDidLoad で変更したコード
locationManager =[[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];