Search code examples
ioslocationmkmapviewmkannotation

Hide MKUserLocation when MKMapView showsUserLocation == YES


After setting mapView.showsUserLocation to true, is it possible to receive location updates without showing the MKUserLocation bubble? Returning nil in mapView:viewForAnnotation: simply shows the bubble, and returning any other kind of annotation shows an annotation, which I don't want.


Solution

  • You can hide the user location's view in the didAddAnnotationViews delegate method:

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