MapViewPath annotation index?

Is there any way (or any way) you can get the "index path" of the annotation inside the method:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation

I want to do something inside an array according to the annotation. One of the methods that I think I want to copy is to - tableView:cellForRowAtIndexPath:use "indexPath".

I searched a lot, but did not find a result. Or maybe I'm just not good at it. Any link would be greatly appreciated.

+5
source share
2 answers

To answer my own question (how does this work for me):

, - mapView:viewForAnnotation: ( pinView), CustomAnnotation .

[customAnnotation setSomething: data];
- mapView:viewForAnnotation:
{
    pinView = [[[CustomPinView alloc] initWithAnnotation: annotation reuseIdentifier: PinIdentifier] autorelease];
}
- initWithAnnotation:reuseIdentifier:
{
    CustomAnnotation *customAnnotation = (CustomAnnotation *)annotation;

    [customAnnotation something];
}

, .

-1
NSUInteger index = [mapView.annotations indexOfObject:annotation];

, , index . , -, indexPath , .

+4

All Articles