2014-02-10 49 views
6

我通過應用程序委託的applicationDidEnterBackground方法在MKMapView對象上設置showsUserLocation = NO。這是爲了阻止它在後臺更新用戶的位置以節省電量。但是,我似乎接受這樣的少數崩潰日誌:MKMapView showsUserLocation崩潰

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 

什麼是立即進入,沒有它崩潰的背景之前停止該用戶的位置更新的最佳方式?我尋找解決這個問題的辦法,但找不到一個。

+2

在將showsUserLocation設置爲NO之前,嘗試將地圖視圖的委託設置爲零。 – Anna

+0

嗨傑克做了這個建議@安娜爲你做了什麼?我有同樣的問題,但我還沒有能夠重現它。只是很多亂七八糟的崩潰報告。 – horsejockey

+0

將代理設置爲nil在我的經驗中沒有解決這個問題。但是它似乎本地化爲iOS 7.x – Kevin

回答

0

一個可能的解決辦法是做到以下幾點:

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

有些事情,你可以嘗試披着通話用:

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

由於地圖似乎認爲註解已被刪除。但在這種情況下,您仍然不會禁用跟蹤。另一種選擇是僅僅在iOS 7中不這樣做,因爲我認爲他已經在8.x中解決了。至少在前者中,即使大多數情況下標註已被選中,您也可以禁用跟蹤。

只是通過在牆壁上的東西。