【发布时间】:2012-09-28 17:52:31
【问题描述】:
Resize MKAnnotationView Image When map zooms in and out?这个方法在iOS5上成功,在iOS6上失败。
我直接更改了 MKAnnotationView 的变换,没有运气。 MKAnnotationView 只在一瞬间调整大小(当在 MKMapView 内部进行 touch up 时,在 touch up 完成后,MKAnnotationView 会恢复原来的大小)。
我的代码如下:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
for (id <MKAnnotation>annotation in _mapView.annotations) {
// if it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
continue;
// handle our custom annotations
//
if ([annotation isKindOfClass:[XPMKAnnotation class]])
{
// try to retrieve an existing pin view first
MKAnnotationView *pinView = [_mapView viewForAnnotation:annotation];
//resize the pin view
double zoomLevel = [_mapView getZoomLevel];
double scale = (1.0 * zoomLevel / 16) + 0.5;
pinView.transform = CGAffineTransformMakeScale(scale, scale);
}
}
}
我们可以在 iOS6 上调整 MKAnnotationView 的大小吗?有人知道吗?
【问题讨论】:
-
这里有同样的问题。我的看起来像是在闪烁,好像变换一直在为 AnnotationView 重置。如果我找到解决方案,将在此处发布。
标签: mkmapview mkannotationview