Show callout when tapping overlay

后端 未结 1 2039
逝去的感伤
逝去的感伤 2021-02-10 18:31

I have an MKMapView with several overlays. Works all just fine, and it\'s incredible how simple it works. There is, however, one thing I can\'t get to work. The idea is simple:

相关标签:
1条回答
  • 2021-02-10 19:11

    I suppose you have to add the MKOverlays as annotations also

     [self.mapView addAnnotations:myOverlays];
    

    Then return a MKAnnotationView in (mapView:viewForAnnotation) that's not hidden, either a graphic (tap-able) or zero alpha view. Next, add a UITapGestureRecognizer for each MKOverlayView, make sure it works with the map's gestures (UIGestureRecognizerDelegate implementation for simultaneous recognition). Finally when your gesture recognizer fires do this

    [self.mapView setSelectedAnnotations:[NSArray arrayWithObject:myOverlayView.overlay]];
    

    I'm not certain that this actually triggers the callOut showing though. Also make sure your return title and/or subtitle from your overlay object.

    0 讨论(0)
提交回复
热议问题