自定义标注、弹出窗口和蓝色精度圆圈的当前位置

9

经过2小时的谷歌搜索,我找不到答案,所以这是我的最后一次尝试。

我想在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;  
    }

感谢您的任何建议。祝好,Christian。
1个回答

7

好的,所以我最终删除了自定义通知,但添加了一个自动弹出的提示。就像这样:

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];
}

如果没有延迟,呼叫不会显示出来。


1
找了大约4个小时,谢谢! - SaifDeen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接