Jak*_*ton 6 objective-c mkmapview ios
我通过app delegate的applicationDidEnterBackground方法在MKMapView对象上设置showsUserLocation = NO.这是为了阻止它在后台更新用户的位置以节省电池电量.但是,我似乎收到了这样的少量崩溃日志:
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
Run Code Online (Sandbox Code Playgroud)
什么是在进入后台之前立即停止用户位置更新而不崩溃的最佳方法?我搜索了这个问题的解决方案,找不到一个.
一个可能的解决方案是执行以下操作:
if ([annotation isKindOfClass:[MKUserLocation class]]) {
((MKUserLocation *)annotation).title = @"My Current Location";
return nil; //return nil to use default blue dot view
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
545 次 |
| 最近记录: |