Ado*_*lfo 3 iphone mkpinannotationview mkmapview
我正在尝试在MKPinAnnotationView后面添加一个图像.看起来这应该很容易在这里做到这一点:
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
for (MKAnnotationView *aView in views)
[[aView superview] addSubview:imageView];
}
Run Code Online (Sandbox Code Playgroud)
但我遇到的问题是,针脚的子视图将呈现在它之上而不是它背后.
我也尝试过:
for (MKAnnotationView *aView in views)
[[aView superview] insertSubview:imageView atIndex:1];
Run Code Online (Sandbox Code Playgroud)
这个问题是,当它在引脚后面时,一旦地图重新定位,图像就会浮出屏幕.
有什么建议?谢谢
感谢您的输入,这里基本上是我没有子类化的结果:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation {
MKAnnotationView *annView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
UIImage *image = [UIImage imageNamed:@"image.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[annView addSubview:imageView];
[imageView release];
MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
[annView addSubview:pinView];
[pinView release];
return annView;
}
Run Code Online (Sandbox Code Playgroud)
我只需要一个引脚,所以我设置reuseIdentifier为nil.
| 归档时间: |
|
| 查看次数: |
14029 次 |
| 最近记录: |