默认用户位置图钉上的标注 AccessoryView
显示用户位置时,是否可以将 CalloutAccessoryView 添加到默认图钉(脉冲蓝点,精确圆圈)。在下面的代码中,您创建自己的 pin 并在注释不是用户位置时添加“pinView.rightCalloutAccessoryView”,当它是用户位置但仍使用默认 pin 时可以完成此操作还是必须使用自己的 pin用于此功能的引脚?
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id )annotation
{
MKPinAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil )
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorGreen;
pinView.canShowCallout = YES;
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.animatesDrop = YES;
}
else
[mapView.userLocation setTitle:@"I am here"];
return pinView;
}
谢谢。
Is it possible to add a CalloutAccessoryView to the default pin (pulsing blue dot, with accuracy cirle) when showing the user location. In the code below you create your own pin and add the 'pinView.rightCalloutAccessoryView' when the annotation is not the user location, can this be done when it is the user location but still using the default pin or do you have to use your own pins for this functionality?
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id )annotation
{
MKPinAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil )
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorGreen;
pinView.canShowCallout = YES;
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.animatesDrop = YES;
}
else
[mapView.userLocation setTitle:@"I am here"];
return pinView;
}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论