问题描述
|
我使用以下方法在我的mapView上显示MKAnnotation View。但是我们这样做是为了给用户的当前位置提供与其他引脚相同的视图。如何使当前位置成为唯一的图钉颜色
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:@\"currentloc\"];
//annView.pinColor = MKPinAnnotationColorGreen;
UIButton *myDetailButton = [UIButton buttonWithType:UIButtonTypeDetaildisclosure];
myDetailButton.frame = CGRectMake(0,23,23);
myDetailButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
myDetailButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[myDetailButton addTarget:self
action:nil/*@selector(checkButtonTapped:event:)*/
forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = myDetailButton;
annView.animatesDrop=NO;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5,5);
return annView;
}
解决方法
在
viewForAnnotation
方法中,检查注释是否为MKUserLocation的实例。如果是,返回nil
:
if ([annotation isMemberOfClass:[MKUserLocation class]]) return nil;