しばらくの間、注釈ボタンを使用して別の mapView に切り替える方法を理解しようとしています。私が取り組んでいるアプリは、MapBox - マップを使用しています。それらが提供する例を確認しましたが、プログラムで2つのマップを切り替えることは常にタブバーを介して行われます(これは私が使用したい場合ではありません)。私はストーリーボードで作業しており、インターフェイスビルダーでセグエを作成する方法をよく理解していましたが、マップビューのプログラムで統合されたボタンで管理していないと思います。両方のヘッダー ファイルで「id」を開始し、Identity Inspector でも宣言しました。
これはコードの一部であり、メイン ビュー コントローラー (ViewController) に注釈を付けて RMMMapView を実装すると、完全に機能します。
- (void)viewDidLoad{
[super viewDidLoad];
RMMapBoxSource *onlineSource = [[RMMapBoxSource alloc] initWithMapID:(([[UIScreen mainScreen] scale] > 1.0) ? kRetinaMapID : kNormalMapID)];
_mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:onlineSource];
_mapView.tileSource = [[RMMapBoxSource alloc] initWithMapID:(([[UIScreen mainScreen] scale] > 1.0) ? kRetinaMapID : kNormalMapID)];
_mapView.centerCoordinate = CLLocationCoordinate2DMake(0,0);
_mapView.adjustTilesForRetinaDisplay = YES;
_mapView.zoom = 4;
_mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:_mapView];
_mapView.showsUserLocation = YES;
[_mapView setConstraintsSouthWest:[_mapView.tileSource latitudeLongitudeBoundingBox].southWest
northEast:[_mapView.tileSource latitudeLongitudeBoundingBox].northEast];
RMPointAnnotation *annotation = [[RMPointAnnotation alloc] initWithMapView:_mapView
coordinate:_mapView.centerCoordinate andTitle:@"Hello, world!"];
[_mapView addAnnotation:annotation];
}
これは、ViewController - main ViewController から LowContentMap viewController を呼び出そうとする部分です。
- (void) prepareForSegue:(UIStoryboardSegue *) segue sender:(id) sender {
if ([segue.identifier isEqualToString:@"Hello, world!"]) {
//LowContentMap *lowContentMap = segue.destinationViewController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
LowContentMap *lowContentMap = [storyboard instantiateViewControllerWithIdentifier:@"lowContentMap"];
lowContentMap.lcm = _vc;
}}
これは、入力する必要があるコードの一部です。
- (void)mapView:(RMMapView *)mapView annotationView:(RMPointAnnotation *)annotation calloutAccessoryControlTapped:(UIControl *)control{
[self performSegueWithIdentifier:@"ShowSomeViewController" sender:annotation];
}
誰かが問題を解決しようとするなら、それは本当に素晴らしいことです. Noa と Kronos の間の議論に従いました: Segue を 使用して詳細ビュー コントローラーをセットアップします が、「id」の部分は私が間違っていると思います。前もって感謝します。