以下代码返回“未选择注释” CalloutAccessories 委托有助于确定选择了哪个注释。我的代码如下。有任何想法吗)?提前致谢
“删除视图控制器.m”
- (IBAction)removePin:(id)sender {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[appDelegate viewController] removeAnno];
[self.navigationController popViewControllerAnimated:YES];
}
“视图控制器.m”
- (void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
if ([(UIButton*)control buttonType] == UIButtonTypeDetailDisclosure){
// Do your thing when the detailDisclosureButton is touched
RemoveViewController *settingAnnotation = [[RemoveViewController alloc]initWithNibName:@"RemoveViewController" bundle:nil];
Annotation *annotation1;
annotation1 = view.annotation;
settingAnnotation.title = annotation1.title;
settingAnnotation.subtitle = annotation1.subtitle;
[self.navigationController pushViewController:settingAnnotation animated:YES];
}
}
- (void)removeAnno{
[mapView removeAnnotations: mapView.selectedAnnotations];
if (mapView.selectedAnnotations.count == 0)
{
NSLog(@"no annotation selected");
}
else
{
id<MKAnnotation> ann = [mapView.selectedAnnotations objectAtIndex:0];
CLLocationCoordinate2D coord = ann.coordinate;
NSLog(@"lat = %f, lon = %f", coord.latitude, coord.longitude);
}
}