-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Touching custom contentView will close the calloutView #62
Comments
So I just tried reproducing this in the sample project - I added a |
My custom I've noticed that if I tap closer to the edges of the callout (and outside the Also using the sample project, I've added to MapKitComparisonController.m, line 104: |
Hmm, you're right, that is strange. I suspect this has something to do with MapKit's built-in gesture recognizers. Somehow |
@nfarina I found sort of a workaround that should work in all cases where no user interaction is intended to the In my case, I have only |
I'm try add breakpoint at first line of method 'calloutClicked' in file SMCalloutView.m and this has no effect. This method not calling when I tap calloutView. |
Hello, what kind of view is the callout being presented in? Are you using a |
Hello! I found error. All will be work if we sending our MKMapView in method |
Yes the problem here is that, in those map controls, touch handling is controlled strictly by the map view itself. So you need to do some work to work around that. Check the README for a short discussion on Google's map view, and the Sample project should contain code demoing how to work with MKMapView and receive touches. |
Yes, and we having mistake exactly into Sample project. I using this code into
|
Hello. I probably also faced same issue, but it works for me by overriding I leave writing code but do not know what would be helpful.
I referred to this article. |
FYI, I ran into this issue and was able to fix the problem by tweaking the following line in the overridden Essentially:
becomes
|
Looks like every year we need another update on this ticket, so here's mine. :) I also reproduced this issue on my app. To be explicit, we are doing a custom What I did was expose the internal @property (nonatomic, strong, readonly) UIButton *containerView; // for masking and interaction Then I modified the example // override UIGestureRecognizer's delegate method so we can prevent MKMapView's recognizer from firing
// when we interact with UIControl subclasses inside our callout view.
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isKindOfClass:[UIControl class]])
return NO;
else
return [super gestureRecognizer:gestureRecognizer shouldReceiveTouch:touch];
}
// Allow touches to be sent to our calloutview.
// See this for some discussion of why we need to override this: https://github.com/nfarina/calloutview/pull/9
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *calloutMaybe = [self.calloutView hitTest:[self.calloutView convertPoint:point fromView:self] withEvent:event];
if ([calloutMaybe isKindOfClass:[UIControl class]]) {
return calloutMaybe;
} else if (calloutMaybe) {
return self.calloutView.containerView;
}
return [super hitTest:point withEvent:event];
} This way if the hit test returns a UIControl subclass, then we pass the event on to it, otherwise we fall back to the main @nfarina Let me know if you would like me to provide a PR for it. |
Using the "standard" view (with title + subtitle), if I tap the callout view, nothing will happen (or
calloutViewClicked
will be called, if the delegate is implemented).However if I set a custom
contentView
to mycalloutView
and then tap that custom view, thecalloutView
won't handle the touch. Instead, the map will dismiss it.How can I avoid this behavior and prevent the callout view from hiding?
The text was updated successfully, but these errors were encountered: