iosios5mkmapviewios5.1

MKMapView detect when click in annotation balloon


There is any way to detect the click in the annotation balloon? I wanted that when user do click in a annotation, it will show some information and if the user want to see all the information he should do click again in the balloon (like Android). I have found how to implement

-(void)mapView:MKMapView*)mapView didSelectAnnotationView:MKAnnotationView *)view

but nothing about what I want to do, so is it possible?


Solution

  • If you set up your annotationView to contain an accessory button, which is pretty normal on iOS so users will feel comfortable, then this function will be called on your mapview's delegate when the user taps the accessory

    - (void)mapView:(MKMapView *)map annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control;
    

    From that you can determine which annotation was pressed and what to do about it