2011-07-25 99 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 
} 
相关问题