您需要创建一个UIButton
并将其分配给rightCalloutAccessoryView
您的 MKAnnotationView 的属性。
在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];
}