MKMapView showsUserLocation崩溃 [英] MKMapView showsUserLocation Crash
问题描述
我通过应用程序委托的applicationDidEnterBackground方法在MKMapView对象上设置showsUserLocation = NO.这是为了阻止它在后台更新用户的位置,以节省电池电量.但是,我似乎收到了少量的崩溃日志,如下所示:
I'm setting showsUserLocation = NO on an MKMapView object via the applicationDidEnterBackground method of the app delegate. This is to stop it from updating the user's location whilst in the background to save on battery. However, I seem to be receiving a small number of crash logs like this:
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's the best way of stopping updates for the user's location immediately before going into the background without it crashing? I searched for a solution to this problem and couldn't find one.
推荐答案
可能的解决方案是执行以下操作:
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
}
这篇关于MKMapView showsUserLocation崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!