开发者

Display selectedAnnotation info

开发者 https://www.devze.com 2023-02-02 22:04 出处:网络
When I use this: - (void)mapView开发者_如何学编程:(MKMapView *)myMapView annotationView:(MKAnnotationView *)view

When I use this:

- (void)mapView开发者_如何学编程:(MKMapView *)myMapView annotationView:(MKAnnotationView *)view 
        calloutAccessoryControlTapped:(UIControl *)control
{
    NSLog(@"SelectedAnnotations is %@", myMapView.selectedAnnotations);
}

It Displays this in the log.

"<Annotation: 0x586cdb0>"

Now this is a weird question, but how do I get the info from this Annotation? I have lost my mind.

This is what is in the annotation.

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 ]];

Thanks for your help.


In calloutAccessoryControlTapped, the annotation tapped is available in the MKAnnotationView parameter:

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

精彩评论

暂无评论...
验证码 换一张
取 消