在MKMap中设置区域后,区域中的跨度会自动更改为两次



>伙计们。

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

我的代码是

- (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

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

谁能把我赶出去??谢谢~~

跨度变化似乎是正常的:为什么 MKCoordinateSpan 会改变?

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

span = self.mapView.region.span;

相关内容

  • 没有找到相关文章

最新更新