2013-05-31 31 views
0

在我的viewForAnnotation方法中,我在針的右側添加了一個細節披露按鈕,但它將showsUserLocation更改爲紅色針,並且披露按鈕位於右側「當前位置」文本。viewForAnnotation細節披露更改當前位置以及針腳

如何阻止當前位置符號被鎖定?沒有這個方法就沒有問題。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { 

    static NSString *identifier = @"MyLocation"; 

     MKPinAnnotationView *annotationView = 
     (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; 

     if (annotationView == nil) { 
      annotationView = [[MKPinAnnotationView alloc] 
           initWithAnnotation:annotation 
           reuseIdentifier:identifier]; 
     } else { 
      annotationView.annotation = annotation; 
     } 

     annotationView.enabled = YES; 
     annotationView.canShowCallout = YES; 

     // Create a UIButton object to add on the 
     UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     [rightButton setTitle:annotation.title forState:UIControlStateHighlighted]; 
     [annotationView setRightCalloutAccessoryView:rightButton]; 

    return annotationView; 
} 

回答

4

加入

if (annotation == mapView.userLocation) { 
    return nil; 
} 
+0

嘿!我正在踢自己的男人我沒有想到這個!仍然在掌握語言,但這似乎非常明顯!感謝您的幫助:) –