对此并不感到自豪,但是...我确实想出了一个解决方案。我根据用于设置 tableview 的数组的索引为各个注释设置标签值。
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
//So, we clicked that disclosure button
//TODO: This is really hacky... What is proper way to do this?
ServicesViewController *vc = [self.navigationController.viewControllers objectAtIndex:1];
[vc infoButtonPressed:control.tag];
}
现在在 ServicesViewController 中我们可以这样做:
- (void) infoButtonPressed:(NSInteger) index {
// decided against this first step, as graver's answer explains, it does not really make sense
//[self.navigationController popViewControllerAnimated:false];
//index should be nav array index we want to push
//so simulate a table-row click
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
}