2011-07-25 12 views
0

私のアプリケーションでは、マップキットを使用しています。私はいつも地図上に複数のアノテーションを持っています。コールアウトでは、detailDisclosureButtonを配置しました。このボタンをクリックすると、新しいviewControllerをロードします。これを行う方法?詳細の開示ボタンのクリックで新しいビューを呼び出す

ありがとうございます。

答えて

2

はとして開示ボタンを追加

-(IBAction) infoButtonPressed:(id) sender 
{ 
    DetailViewController *dvc = [[DetailViewController alloc] init]; 
    [self.navigationController pushViewController:dvc animated:YES]; 
} 
+0

s。セレクタ ":"にはありません。 (infoButtonPressed)のみにする必要があります。 – Harsh

+0

送信者のインスタンスが必要かどうかは、あなたに依存します。 – saadnib

0

ここでは、Modal View Controller Referenceを確認して、あるビューから別のビューに移動する方法を確認します。 detailDisclosureButtonが押されたら、移動したいviewControllerを設定し、リンクに記述されているメソッドを使用します。希望が助けてくれる!

UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
[infoButton addTarget:self action:@selector(infoButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
pinView.rightCalloutAccessoryView = infoButton; 

とそのアクションメソッドで - - - (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id)annotationデリゲートで

1
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation 
{ 

    //Some code here 
    pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

    return pinView; 
} 

とボタンのアクションを取得するには、次のデリゲートメソッドを利用する

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { 
// code to show details view 
} 
関連する問題