2011-07-25 46 views
0

在我的應用程序中,我使用的是mapkit。我一直在地圖上有多個annoatations。在標註中,我放置了detailDisclosureButton。點擊這個按鈕我想加載新的viewController。這個怎麼做?通過點擊詳細信息按鈕調用新視圖

在此先感謝。

回答

2

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id)annotation委託添加披露按鈕 -

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

,並在其操作方法 -

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

它的工作秒。在選擇器「:」不在那裏。它應該只有(infoButtonPressed)。 – Harsh

+0

它取決於你是否需要發件人實例。 – saadnib

0

我會在這裏檢查:Modal View Controller Reference以瞭解如何從一個視圖移動到另一個視圖。當按下detailDisclosureButton時,設置要移動到的viewController,並使用鏈接中描述的方法。希望有所幫助!

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 
} 
相關問題