MKMapView shows UserLocation Crash

I set showUserLocation = NO in the MKMapView object using the application delegate applicationDidEnterBackground method. This is done so that it does not update the user's location in the background in order to save on battery. However, it seems I am getting a small number of crash logs, for example:

0 MapKit 0x3174c5f6 <redacted> + 9 1 MapKit 0x3174c5e9 -[MKQuadTrie contains:] + 24 2 MapKit 0x3176eaa7 -[MKAnnotationManager _removeAnnotation:updateVisible:removeFromContainer:] + 50 3 MapKit 0x3176ea6d -[MKAnnotationManager removeAnnotation:] + 28 4 MapKit 0x31782283 -[MKMapView stopUpdatingUserLocation] + 118 

What is the best way to stop updates for a user's location immediately before entering the background without crashing? I was looking for a solution to this problem and could not find it.

+6
source share
2 answers

A possible solution would be to do the following:

 if ([annotation isKindOfClass:[MKUserLocation class]]) { ((MKUserLocation *)annotation).title = @"My Current Location"; return nil; //return nil to use default blue dot view } 
0
source

Something you could try is to wrap the call:

 if (myMapView.userLocationVisible) { myMapView.showsUserLocation = NO; } 

Since the map seems that the annotation has been deleted. However, in this case, you will not disable tracking. Another option is to simply not do this for iOS 7, since I think it was resolved in 8.x. At least in the first, you could turn off tracking, even if the annotation was rejected for you most of the time.

Just through things against the wall at the moment.

0
source

All Articles