Question

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.

Was it helpful?

Solution

MKMapViewDelegate has a method:

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

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top