Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom MKAnnotationView intermittently recognize touch
    primarykey
    data
    text
    <p>I have a custom <code>MKAnnotationView</code> that I am loading from an <code>XIB</code>. When I first load the mapview, I have several standard <code>MKAnnotationView</code>. </p> <p>When a user selects one, the custom <code>MKAnnotationView</code> is presented. I would like for the user to be able to tap anywhere inside the custom annotation view to present a new view controller.</p> <p>What I've tried (all of these were suggestions I found here on StackOverflow):</p> <ul> <li>Overriding hit test is the custom MKAnnotationView class. The issue here is that CGPoint would return as nil most of the time. (<a href="https://stackoverflow.com/questions/8648263/how-do-i-make-a-mkannotationview-touch-sensitive">How do I make a MKAnnotationView touch sensitive?</a>)</li> <li>Adding a tap gesture to a UIButton and adding that button to the custom annotation view in the viewForAnnotation delegate method. (<a href="https://stackoverflow.com/questions/6941199/how-to-get-click-event-from-a-button-added-over-mkannotationview">How to get click event from a button added over MKAnnotationView</a>). This never really worked and it didn't make much sense to me. Adding a tap gesture to a button seems redundant. </li> <li>Adding KVO to the annotation view. (<a href="http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/" rel="nofollow noreferrer">http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/</a>). This caused an issue because the annotationView that was added to the map seemed to get deallocated before sending the notification.</li> <li>Adding a clear button in the XIB that is the size of the custom view and adding a target/selector to it. I also make sure to bring it to the front of the parent view.</li> </ul> <p>What is strange is that if I drag the map while the annotation is present, the button works fine. The issue only shows up when I first show the custom view.</p> <p>Any ideas would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload