2016-03-11 206 views
0

我已经设置好让我的MKMapView显示当前位置。我还为其他引脚实现了一个定制引脚。然而,事实证明,当前位置显示为自定义引脚,而我只是希望它是一个普通的蓝色圆圈(就像谷歌地图所具有的一样)。显示当前位置MKMapView

我已经定义在我的代码如下:

- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id<MKAnnotation>) annotation MKAnnotationView *pin = (MKAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"VoteSpotPin"]; 
    if (pin == nil) 
    { 
     pin = [[[MKAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"TestPin"] autorelease]; 
    } 
    else 
    { 
     pin.annotation = annotation; 
    } 

    [pin setImage:[UIImage imageNamed:@"TestPin.png"]]; 
    pin.canShowCallout = YES; 
    pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    return pin; 
} 

如何防止当前位置显示为一针?

回答

0

试试这个: -

- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation:(id<MKAnnotation>) annotation 
{   
    if (annotation == mapView.userLocation) 
    { 
     return nil; 
    } 
    else 
    { 
     MKAnnotationView *pin = (MKAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"VoteSpotPin"]; 
     if (pin == nil) 
     { 
      pin = [[[MKAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"TestPin"] autorelease]; 
     } 
     else 
     { 
      pin.annotation = annotation; 
     }   

     [pin setImage:[UIImage imageNamed:@"TestPin.png"]]; 
     pin.canShowCallout = YES; 
     pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     return pin; 
    } 
} 
+0

OKY我会尝试... –

相关问题