2013-02-01 23 views
1

我的MKMapView有點問題。iPhone Objective C MKMapView在第一次打開時不放大

如果我打開它,它應該中心的引腳(可以只有一個引腳)和縮放到此引腳。 工作總是非常好,但是當我第一次打開地圖時,它只會將引腳居中,但會縮小到最大。

這是我的代碼:

- (void) viewDidAppear:(BOOL)animated 
{ 
    if(self.curPin != nil){ 
     [self.map setCenterCoordinate: self.curPin.coordinate]; 
    } 
    else{ 
     [self.map setCenterCoordinate:locationManager.location.coordinate]; 
    } 
} 

curPin是CLLocation,在那裏我救我的腳的座標。

希望任何人都可以幫助我。

謝謝,弗朗茲

+0

請變焦[這](http://troybrant.net/blog/2010/01/set-the-zoom-level-of- an-mkmapview /)教程 – swiftBoy

回答

0

您可以用setRegion

 MKCoordinateRegion location = MKCoordinateRegionMakeWithDistance(currentAnnotation.coordinate, 100000.0, 100000.0); 
     //MKCoordinateSpan span = {.2, .3}; 
     //location.span=span; 

     [self.map setRegion:location animated:YES]; 
+0

感謝提示 它工作得很好 不是最好的方式,但我也喜歡這個) 非常感謝你! –

+0

爲什麼你覺得它不是最好? – Rajneesh071

1

你還應該設置地圖的跨度?我希望你做的..

MKCoordinateSpan span; 
span.latitudeDelta = 0.2; 
span.longitudeDelta= 0.2; 

MKCoordinateRegion mapRegion; 
    mapRegion.span = span; 

試試這個..因爲這將設置你的地圖視圖的跨度。我希望它有幫助,乾杯!快樂編碼..

+0

謝謝。我已經嘗試過,但仍然存在相同的問題。 :( –

相關問題