I have a really simple question: how can I check if an MKAnnotation is selected on a map?
I can't see a selected like (GET) property.
I hope the solution would not be by triggering selected/deselected events and store its result in a property and check them if I need. There must be a more straightforward one.
Thanks very much!
Check out -[MKMapView selectedAnnotations]
.
Making use of the delegate method of MKMapView didSelectAnnotationView:
use can get the event MKAnnotation Selected
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
// Annotation is your custom class that holds information about the annotation
if ([view.annotation isKindOfClass:[Annotation class]]) {
Annotation *annot = view.annotation;
NSInteger index = [self.arrayOfAnnotations indexOfObject:annot];
}
}
Hope it will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With