如何解决iPhone:MKMapAnnotationView:当前位置具有与其他图钉相同的注解视图如何使其独特?
| 我使用以下方法在我的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;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。