如何在图钉顶部显示用户位置图标?

时间:2014-01-20 14:34:28

标签: ios mkmapview mkannotation

如何在地图视图图钉图像的顶部显示用户位置图标(蓝点)。 现在,用户位置图标被图钉图像隐藏了(在图钉图像下方)。

如何完成此任务?(查看截图)

是否可以在图像顶部显示用户位置图标?

谢谢。 enter image description here

3 个答案:

答案 0 :(得分:1)

您可以获取userLocation的注释并将其视图置于最前面。

MKAnnotationView *annotationView = [self.mapView viewForAnnotation:self.mapView.userLocation];
[annotationView.superView bringSubviewToFront:annotationView];

答案 1 :(得分:0)

这可能是因为您正在覆盖userLocation的注释视图。

在地图视图委托方法- mapView:viewForAnnotation:上,您可以执行以下操作:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
  <YourAnnotationViewClass> *annotationView = nil;

  if (annotation != [mapView userLocation]) {
    // Add custom annotation view
  }

  return annotationView;
}

annotation == [mapView userLocation]的情况下,如果您返回nil,则会使用默认注释(在这种情况下为蓝色圆圈)。

答案 2 :(得分:-1)

i = 0
numbers = [1, 1, 1, 1, 1]

try:
    while True:
        print(numbers[i])
        i += 1
except IndexError:
    print("Run out of numbers")
相关问题