Dan
Dan

Reputation: 151

iPhone: How to reenable MKUserLocation 'blue dot'?

Enabling the 'blue dot' which shows current location in my application by

mapView.showsUserLocation = YES

Disabling/hiding the dot by

mapView.showsUserLocation = NO

in order to drop a pin. So far so good.

Adding an annotation pin at 'userLocation' and dragging it around in the map to a new location. After that I want to show the blue dot again by setting showsUserLocation to YES again - but it simply does not show up! What could be the problem? Is there a way to force it to show again (reset userLocation?) with any other method? Which events are involved?

Grateful for any help on this one..

Upvotes: 0

Views: 2372

Answers (2)

Will Johnston
Will Johnston

Reputation: 864

Try this:

if ([annotation isKindOfClass:[MKUserLocation class]])  return nil;

Using the class rather than annotation==_mapView.userLocation means that is you stop using _mapView.userLocation or whatever, this line does not break.

Upvotes: 3

Tuğrul Özdemir
Tuğrul Özdemir

Reputation: 76

check if you are customizing your annotationView with - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation method try:

if (annotation==_mapView.userLocation ) {
    return nil;
}
else {
    //...
    //costumizing pins for other annotations on mapview

    //return customized annotationview
}

Upvotes: 3

Related Questions