Question

guys.

I met this problem this afternoon. I don't want a different span....

My code is

- (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);
}

and the log is

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

I found this problem happens on the last annotation of the annotationList.

Could anyone hepls me out?? Thanks~~

Was it helpful?

Solution

Seems it's normal that the span changes: Why MKCoordinateSpan changes?

If you simply remove the following line it'll always stay the initial span:

span = self.mapView.region.span;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top