I have a normal map in my iOS app where "Shows Users Location" is enabled - meaning I have my normal blue dot on the map, showing my position and accuracy info. The callout is disabled in code.
But I also have custom MKAnnotationViews that are plotted around the map which all have custom callouts.
This is working fine, but the problem is that when my location is on the location of a MKAnnotationView, the blue dot (MKUserLocation) intercepts the touch, so the MKAnnotationView doesn't get touched.
How can I disable the user interaction on the blue dot so that the touches are intercepted by the MKAnnotationViews and not the blue dot?
This is what I do so far:
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation;
{
if (annotation == self.mapView.userLocation)
{
[self.mapView viewForAnnotation:annotation].canShowCallout = NO;
return [self.mapView viewForAnnotation:annotation];
} else {
...
}
}
Disabling the callout doesn't disable touches on the view (
didSelectAnnotationViewwill still get called).To disable user interaction on an annotation view, set its
enabledproperty toNO.However, instead of setting
enabledtoNOin theviewForAnnotationdelegate method, I suggest doing it in thedidAddAnnotationViewsdelegate method instead and inviewForAnnotation, just returnnilforMKUserLocation.Example: