2013-03-10 74 views
2

我Implementet這樣的:註釋引腳用作用戶位置

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

    MKPinAnnotationView *pinView = nil; 

     static NSString *defaultPinID = @"Place to be"; 
     pinView = (MKPinAnnotationView *)[self.myMapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
     if (pinView == nil) pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID]; 

     pinView.pinColor = MKPinAnnotationColorRed; 
     pinView.canShowCallout = YES; 
     pinView.animatesDrop = YES; 


     UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     [rightButton addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; 
     pinView.rightCalloutAccessoryView = rightButton; 

     return pinView; 
} 

我現在的問題是,用戶位置被出示一張一針... ?我怎樣才能回藍點?

感謝

+0

看到這個問題的答案:http://stackoverflow.com/questions/11767240/how-to-stop-the-viewforannotation-method-from-overriding -THE-默認用戶locati – Craig 2013-03-10 06:56:57

回答

1

試試這個

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

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


    MKPinAnnotationView *pinView = nil; 

    static NSString *defaultPinID = @"Place to be"; 
    pinView = (MKPinAnnotationView *)[self.myMapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
    if (pinView == nil) pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID]; 

    pinView.pinColor = MKPinAnnotationColorRed; 
    pinView.canShowCallout = YES; 
    pinView.animatesDrop = YES; 


    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [rightButton addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; 
    pinView.rightCalloutAccessoryView = rightButton; 

    return pinView; 
}