Just an update to this -- in iOS 4 there are MKMapViewDelegate
methods that can be used to track annotation selection and de-selection:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
You can use an Observer for Selected annotation Event:
[pin addObserver:self
forKeyPath:@"selected"
options:NSKeyValueObservingOptionNew
context:@"ANSELECTED"];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
NSString *action = (NSString*)context;
if([action isEqualToString:@"ANSELECTED"]){
BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];
if (annotationAppeared) {
// clicked on an Annotation
}
else {
// Annotation disselected
}
}
}