I try to capture events on a subclassed MKOverlayView with a UIGestureRecognizer.
However the selector never gets fired. Any ideas?
interface:
#import <MapKit/MapKit.h>
@interface XYOverlayView : MKCircleView {}
-(void) viewTapped:(UIGestureRecognizer *)gestureRecognizer;
@end
imp:
@implementation XYOverlayView
- (id)initWithOverlay:(id <MKOverlay>)overlay
{
if(self = [super initWithOverlay:overlay])
{
self.userInteractionEnabled = TRUE;
self.multipleTouchEnabled = TRUE;
UITapGestureRecognizer *tapRecogniser = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
[self addGestureRecognizer:tapRecogniser];
[tapRecogniser release];
}
return self;
}
-(void) viewTapped:(UIGestureRecognizer *)gestureRecognizer
{
NSLog(@"XYOverlayView tapped");
}
@end
Did not get this to work. Switched to an custom MKAnnotationView to capture the gestures. This also has the advantage the tapable region in the window stays the same size.