Hi,
I'm trying to intercept touch events from a MKMapView. From various discussions around the internet I gathered that it is impossible to get the touch events received by MKMapView directly. So, I created a UIView subclass EventHandlingView
that intercepts touch events. So, in my view controller, I first add the MKMapView instance as a subview and then, I add my EventHandlingView as another subview on top of the MKMapView:
...
[self.view addSubview:myMapView];
[self.view addSubview:myEventHandlingView];
...
In EventHandlingView
, I override the event handling related methods:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
// touchedView is a global UIView* ivar.
touchedView = [super hitTest:point withEvent:event];
return self;
}
And all the touches...:withEvents:
methods like this:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// I handle the event here. Then I want to pass it on to the MKMapView
[touchedView touchesBegan:touches withEvent:event];
}
All my methods inside EventHandlingView
get called, but for some reason they don't get passed on to the map view. What am I doing wrong?