Disable MKmapkit mapView userLocation annotationView

I have a mapView with annotationViews and a blue dot userLocation .

I use the following code to get the blue dot:

 [self.mapView setShowsUserLocation:YES]; 

annotationViews are selectable and have callouts.

However, if the annotationView is close to the user's location, sometimes the blue dot steals the touch.

I can set annotationView.enabled = NO; and it will show annotationView, but it will not steal a touch from closing annotationView .

I would like to set the user's location with the blue dot annotationView to enabled = NO, so it does not steal the close touch on annotationViews .

I can set the title of the blue dot with:

 self.mapView.userLocation.title = @"title here..." 

But I can not turn off the blue dot.

Thanks!

+6
source share
1 answer

You can set enabled to a custom MKAnnotationView location by getting a link to it in the didAddAnnotationViews delegate didAddAnnotationViews (so you can make sure the view is ready):

 -(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { MKAnnotationView *ulv = [mapView viewForAnnotation:mapView.userLocation]; ulv.enabled = NO; } 

(There is no enabled object in the userLocation model userLocation - this is a view property.)

+8
source

Source: https://habr.com/ru/post/927215/


All Articles