显示selectedAnnotation信息

时间:2011-01-05 18:49:56

标签: iphone mapkit mkmapview

当我使用它时:

- (void)mapView:(MKMapView *)myMapView annotationView:(MKAnnotationView *)view 
        calloutAccessoryControlTapped:(UIControl *)control
{
    NSLog(@"SelectedAnnotations is %@", myMapView.selectedAnnotations);
}

它在日志中显示。

"<Annotation: 0x586cdb0>"

现在这是一个奇怪的问题,但我如何从这个注释中获取信息?我已经忘记了。

这是注释中的内容。

myAnnotation = [[Annotation alloc] init];
myAnnotation.dealName=[NSString stringWithFormat:@"%@",[tempValue objectForKey:@"name"]];
myAnnotation.subName=[NSString stringWithFormat:@"Price: $%@",[tempValue objectForKey:@"price"]];
myAnnotation.latitude = [NSNumber numberWithDouble:[[tempValue objectForKey:@"dealLatitude"] doubleValue]];
myAnnotation.longitude = [NSNumber numberWithDouble:[[tempValue objectForKey:@"dealLongitude"] doubleValue]];
myAnnotation.dealId = [NSNumber numberWithInt:[ [tempValue objectForKey:@"dId"] intValue ]];

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

在calloutAccessoryControlTapped中,点击的注释在MKAnnotationView参数中可用:

Annotation *myAnnotation = (Annotation *)view.annotation;