In my iphone app I want to allow the user to tap on the callout bubble to take him to another view how can i add gesture to the bubble
i tried to put gesture on the MKAnnotationView when the user select the annotation
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showItem:)];
tapped.numberOfTapsRequired = 1;
view.userInteractionEnabled = YES;
[view addGestureRecognizer:tapped];
}
but this doesn't work for the bubble any help ?
You've set a gesture recognizer on the annotation view (the pin), not the callout bubble which is a separate view. On top of that, I'm not sure that recognizer will work due to conflicts with the map's recognizers.
As @CyrilGodefroy comments, what you're doing is both harder than and less recognizable to users than is the standard way of putting controls in the callout bubble. The framework provides callout accessory views for this purpose:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
// Add a detail disclosure button to the callout.
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action:@selector(myShowDetailsMethod:) forControlEvents:UIControlEventTouchUpInside];
view.rightCalloutAccessoryView = rightButton;
}