2010-09-02 74 views
0

啓用「藍點」,這是用我自己的應用程序的當前位置由iPhone:如何重新啓用MKUserLocation'藍點'?

mapView.showsUserLocation = YES 

禁用/由

mapView.showsUserLocation = NO 

藏匿點,以放置圖釘。到現在爲止還挺好。

在'userLocation'處添加註釋引腳並將其在地圖中拖動到新位置。之後,我想通過再次將showsUserLocation設置爲YES來再次顯示藍點 - 但它不會顯示出來!可能是什麼問題呢?有沒有辦法強制它再次顯示(重置userLocation?)與任何其他方法?涉及哪些事件?

感激在這一個任何幫助..

回答

3

檢查,如果你正在定製與- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 方法試試你的annotationView:

if (annotation==_mapView.userLocation) { 
    return nil; 
} 
else { 
    //... 
    //costumizing pins for other annotations on mapview 

    //return customized annotationview 
} 
+0

我不知道爲什麼上面的代碼爲我工作。但是,約翰遜的代碼會訣竅。 – 2014-04-17 12:29:01

+0

當我關閉並打開位置服務時,它不起作用。 – 2014-04-17 12:31:25

3

試試這個:

if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; 

使用類,而比註解== _ mapView.userLocation意味着你停止使用_mapView.userLocation或者其他東西,這行不會中斷。