Note that there are some explanatory texts on larger screens.

plurals
  1. POPrevent touch propagation to annotation beneath
    primarykey
    data
    text
    <p>I have a custom <code>MKAnnotationView</code>. In its <code>setselected:animated</code> method I'm adding to it a custom bubble loaded from a nib, adjust the annotationview's frame to include this view and redraw the annotation circle with other color, like this (first - not selected , second - selected, blue - frame, green - custom bubble view with alpha = 0.8, red - the annotationview): </p> <h2><img src="https://i.stack.imgur.com/TsGxe.jpg" alt="enter image description here"></h2> <p>It works fine, the bubble appears, and can be "closed" only by tapping outside of it (this is why I've increased the frame). I have some buttons on this bubble and they are clickable if there is nothing under the annotation just the map.</p> <p>BUT when under the callout bubble there is another annotation I can click "through" the entire bubble. When I tap on one of the buttons, the tap highlight appears, but an other annotation gets selected because the <code>didSelectAnnotationView</code> fires ...</p> <p>I tried to make the bubble opaque/semitransparent, no luck; set exclusiveTouch on buttons, on the view itself, no luck; tried not to mess with frame, still can click through. Am I missing something ? </p> <p>Thanks</p> <p><strong>Edit</strong> : <strong>Shorter: Why can I click through a <code>UIView</code> added in <code>addSubview</code> in an MKAnnotationView if there is other MKAnnotaionView under this UIView ?</strong></p> <p>Details : </p> <pre><code>- (void)setSelected:(BOOL)selected animated:(BOOL)animated { if(selected) { initialFrame = self.frame; // save frame and offset to restore when deselected initialOffset = self.centerOffset; // frame is correct for a circle, like {{2.35, 1.47}, {12, 12}} if (!self.customCallout) { self.customCallout = [[[NSBundle mainBundle] loadNibNamed:@"CustomCallout" owner:self options:nil] objectAtIndex:0]; } // adjust annotationview's frame and center // callout is 200x120, here frame is {{2.35, 1.47}, {200, 132}} self.customCallout.layer.cornerRadius=5; self.customCallout.exclusiveTouch = YES; [self addSubview:self.customCallout]; } ... } </code></pre> <p><code>initWithAnnotation</code> has these : </p> <pre><code> self.canShowCallout = NO; // to appear the subview self.exclusiveTouch = YES; // ... self.enabled = YES; self.opaque = YES; </code></pre>
    singulars
    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.
    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