0

伙计们。

我今天下午遇到了这个问题。我不想要不同的跨度......

我的代码是

- (IBAction)arrowClicked:(id)sender
{
UIButton *button = (UIButton *)sender;
for (Annotation *a in self.mapView.annotations) {
    if (a.tag==button.tag-800) {
        MKCoordinateRegion region = self.mapView.region;
        region.center = a.coordinate;
        region.span = span;
        NSLog(@"%f,%f",region.span.longitudeDelta, region.span.longitudeDelta);
        NSLog(@"%i",a.tag);
        NSLog(@"arrowClicked1  %f,%f",self.mapView.region.span.longitudeDelta, self.mapView.region.span.longitudeDelta);
        NSLog(@"arrowClicked1  %f,%f",region.span.longitudeDelta, region.span.longitudeDelta);
        [self.mapView setRegion:region animated:YES];
        NSLog(@"arrowClicked2  %f,%f",self.mapView.region.span.longitudeDelta, self.mapView.region.span.longitudeDelta);
        [self.mapView selectAnnotation:a animated:NO];
        break;
    }
}
}

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
{
NSLog(@"will changed");
for (UIImageView *arrow in self.mapView.subviews) {
    if (arrow.tag>=800) {
        [arrow removeFromSuperview];
    }
}
NSLog(@"regionWillChangeAnimated  %f,%f",self.mapView.region.span.longitudeDelta, self.mapView.region.span.longitudeDelta);
}

日志是

2012-04-11 20:23:46.471 SFMap[4113:11603] 103
2012-04-11 20:23:46.471 SFMap[4113:11603] arrowClicked1  0.109863,0.109863
2012-04-11 20:23:46.472 SFMap[4113:11603] arrowClicked1  0.109863,0.109863
2012-04-11 20:23:46.472 SFMap[4113:11603] will changed
2012-04-11 20:23:46.472 SFMap[4113:11603] regionWillChangeAnimated  0.109863,0.109863
2012-04-11 20:23:46.472 SFMap[4113:11603] arrowClicked2  0.219727,0.219727

我发现这个问题发生在 annotationList 的最后一个注释上。

谁能帮帮我??谢谢~~

4

1 回答 1

1

跨度变化似乎很正常:为什么 MKCoordinateSpan 变化?

如果您只是删除以下行,它将始终保持初始跨度:

span = self.mapView.region.span;
于 2012-04-13T05:34:43.943 回答