点击详细信息披露按钮调用新视图

时间:2011-07-25 05:18:23

标签: iphone

在我的应用程序中,我正在使用mapkit。我一直在地图上有一个以上的日期。在标注中我放置了detailDisclosureButton。单击此按钮,我想加载新的viewController。怎么做?

提前致谢。

3 个答案:

答案 0 :(得分: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];
}

答案 1 :(得分: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
}

答案 2 :(得分:0)

我会在这里查看:Modal View Controller Reference,了解如何从一个视图移动到另一个视图。按下detailDisclosureButton时,设置要移动到的viewController,并使用链接中描述的方法。希望有所帮助!