你需要创建一个UIButton
并将其分配给您的MKAnnotationView的rightCalloutAccessoryView
财产。
在mapView:viewForAnnotation:
方法中,如果您正在返回自定义MKAnnotationView
实例,请插入此代码以创建按钮并将其与操作关联。
我假设你的MKAnnotationView
实例被称为annotationView
,并且你要调用的方法是presentMoreInfo
。
UIButton * disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton addTarget:self
action:@selector(presentMoreInfo)
forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = disclosureButton;
你presentMoreInfo
方法可以是这样的
- (void)presentMoreInfo {
DetailsViewController * detailsVC = [DetailsViewController new];
//configure your view controller
//...
[self.navigationController pushViewController:detailsVC animated:YES];
}
您需要使用自定义的注解视图。 – Lefteris