Git Product home page Git Product logo

Comments (6)

nfarina avatar nfarina commented on June 27, 2024

OK, so this was pretty tricky but I think I figured it out. On iOS 6, MKMapView uses a UIGestureRecognizer to figure out when you've tapped on the map. For some reason, when you attempt to click a UITextField in the callout, this causes the gesture recognizer to fire and the map view to think that you've clicked outside the pin and wish to dismiss the callout.

I've just pushed an example to the master branch that demonstrates how to work around this. The trick is to subclass MKMapView and override the gesture recognizer delegate to swallow touches from UIControl subclasses. Just uncomment the three lines that create a UITextField to see it in action.

Hope this works for you!

from calloutview.

foFox avatar foFox commented on June 27, 2024

Still no luck, could the problem be caused by AutoLayout and/or using much larger view than standard callout created from a nib which also uses auto layout? As well I also have a long press attached to the map.

I noticed that I in that overridden delegate method for gesture recogniser, the touch.view is always MKAnnotationContainerView

I did some printing in the debugger.

http://pastebin.com/GCjd58p5

why does the callout view have negative x/y?

from calloutview.

foFox avatar foFox commented on June 27, 2024

Ok, so main the difference between how your sample code works and what happens when I tap the map in code, is precisely, what is under touch.view. In your case it is indeed what I clicked, button/textfield/etc. In my code its ALWAYS that MKAnnotationContainerView no matter what I click. The weird part, I am pretty much not doing anything else than whats in the sample project.

from calloutview.

nfarina avatar nfarina commented on June 27, 2024

Hm, that's weird. So how did you fix it?

from calloutview.

foFox avatar foFox commented on June 27, 2024

http://pastebin.com/vLuhB8dx

Turns out that altering -pointInside:(CGPoint)point withEvent:(UIEvent *)event inside SMCalloutView by adding
contentViews pointsInside method to be also checked, does the job perfectly. I am not sure if I removed this line before by myself. But it works now.

from calloutview.

nfarina avatar nfarina commented on June 27, 2024

Yeah, I should have explicitly mentioned that, but that was one of the things I fixed when looking into this originally. Glad that did the trick!

from calloutview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.