ストーリーボードには、View Controller との関係にある Navigation Controller があります。
View Controller には MKMapView が含まれています。
View Controller も、Identity Inspector -> Custom Class で、カスタム コントローラー MapViewController になるように設定されています。
これはMapViewController.hです
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "MarkerAnnotation.h"
#import "MarkerButton.h"
#import "MainMapView.h"
@interface MapViewController : UITableViewController <MKMapViewDelegate, CLLocationManagerDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *localMapView;
@end
localMapView は、「参照アウトレット」を介してストーリーボードの ViewController に配置された MKMapView にリンクされています。注釈の設定や「bounds.origin」の取得などのために、.m ファイルのコードで既に使用しています。
ユーザーがマップを移動するたびに、いくつかの行を実行してマップを更新する必要があります。そこで、.m ファイルに mapView:regionDidChangeAnimated: を実装しようとしましたが、これが呼び出されることはありません。
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
NSLog(@"Region changed");
}
そのクラスにメソッドを実装する MKMapView のカスタム サブクラスを作成しようとしましたが、どちらも呼び出されませんでした。(.h ファイル MainMapView.h のインポートでまだ確認できます...まだインポートを削除していません)
足りないものはありますか?マップと現在のクラスの間にさらに接続を設定する必要がありますか?
それ以外の場合、マップが移動するたびにイベントをトリガーできる別の方法はありますか?