经过两个小时的谷歌搜索,我找不到答案,所以这是我最后一次尝试。
我想为用户在mkmapview上的当前位置使用自定义注释。但我也希望它周围有一个蓝色的精确圆。
能做到吗?
如果没有,我可以添加一个调用到默认的带圆圈的蓝点吗?
我之所以需要这样做是因为在我的应用程序中,当前的位置点经常会在其他注释下消失。这就是为什么我用一个紫色的别针作为当前位置。
这是我的注释代码:
if ([annotation isKindOfClass:MKUserLocation.class]) { MKPinAnnotationView *userAnnotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:@"UserLocation"]; if (userAnnotationView == nil) { userAnnotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"UserLocation"]autorelease]; } else userAnnotationView.annotation = annotation; userAnnotationView.enabled = YES; userAnnotationView.animatesDrop = NO; userAnnotationView.pinColor = MKPinAnnotationColorPurple; userAnnotationView.canShowCallout = YES; [self performSelector:@selector(openCallout:) withObject:annotation afterDelay:0.01]; return userAnnotationView; }
谢谢你的建议。干杯,克里斯蒂安
好的,所以我最终删除了自定义通知,但添加了一个自动弹出的调用。这样地:
mapView.showsUserLocation=TRUE; mapView.userLocation.title = NSLocalizedString (@"Here am I",@"Here am I" ); [self performSelector:@selector(openCallout:) withObject:mapView.userLocation afterDelay:3.0];
还有:
- (void)openCallout:(id<MKAnnotation>)annotation { [mapView selectAnnotation:annotation animated:YES]; }
如果不延迟,呼叫将不会出现。