2012-04-11 8 views
0

人。MKMapに領域を設定した後、領域内のスパンが自動的に2回に変更されました

私はこの午後にこの問題に遭遇しました。 私は

私のコードは

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

で、ログが、私はこの問題はannotationListの最後の注釈に起きた

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 

です....異なるスパンをしたくありません。

誰でも私を孤独にすることはできますか?

+0

はちょうどそれを自分自身をテストし、唯一のスパン初めてスパンを設定するときに変更されます。スパン変数は決して変化しませんか? – ggfela

+0

@ggfelaはい、決して変更されていません。私のデリゲートでは、スパンはマップ領域からのみ値を取得するため、変更しないでください。私が見つけられなかった問題を見つけるために私のプロジェクトをあなたにメールすることはできますか? –

+0

確かに、私は見ることができます。 – ggfela

答えて

1

~~ おかげで、それはスパンが変化することを、正常だようだ:Why MKCoordinateSpan changes?

あなたは、単に以下の行を削除した場合、それは常に最初のスパンを滞在されます:

span = self.mapView.region.span; 
+0

haha​​ ~~うまくいきます。 –

+0

ありがとうございます~~ –

関連する問題