I have an app that has a mapview, and it shows 20 pins (from an Array) on the map. When the user clicks on it, it can show a bubble with a right accessory button.
Here come my problem: How do I know which pin was pressed?
I heard something about the mapView:didSelectAnnotationView method, but I don’t really understand how do you get the pin/callout index, so that I can get the information of the object at the same index of my Array? Thanks for any help!
I have an app that has a mapview, and it shows 20 pins (from
Share
When that method gets called — because your viewController class has adopted
MKMapViewDelegate, you can call-indexOfObjecton the array and get the index of that pin (annotation). This is with the assumption that your array holds objects of the kind of annotation class.If you need more explanation, we need to know how you are adding those pins, i.e. implementation of
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation.