user774150
user774150

Reputation: 1072

mkmapview showsUserLocation

Hey have a question here. I'm trying to do.

if (Map.showsUserLocation == YES) 
        {
            Map.showsUserLocation = NO;
        }

This is rather simple. When the app just started showsUserLocation is set to YES, but it takes time for the device to find the location. So if the user click showsUserLocation = NO before the location has been found (before the blue dot appear). EXC_BAD_ACCESS.

In google map, it has the protection code, before google map get the blue dot appear, it will disable you from pressing the showsUserLocation button by displaying the activityIndicator. Any idea how to do this? Thanks in advance.

Upvotes: 1

Views: 2197

Answers (2)

Abdullah Md. Zubair
Abdullah Md. Zubair

Reputation: 3324

You can do quite comfortably. Disable your 'currentLocation' button until mapView get user's current location, then the 'currentLocation' button when get user's current location.You can do this by disabling 'currentLocation' button in viewDidLoad/ViewDidAppear and enable 'currentLocation' button in -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: method after [mapView.userLocation setTitle:@"I am here"];. This will work for you.

Upvotes: 0

MarkPowell
MarkPowell

Reputation: 16540

MKMapViewDelegate has a method:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation

You can enable the button here, until then keep it disabled.

Upvotes: 1

Related Questions