0
我想使用cllocationmanager來獲取我當前的位置。ClLocationManager委託沒有被立即調用?
問題:
委託方法
-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
總是viewdidappear後運行。我在viewDidLoad中啓動了位置。並在viewdidLoad的末尾調用SetMapView方法。
-(void)setMapView{
MKCoordinateRegion zoomIn = plotsMapView.region;
zoomIn.span.latitudeDelta = 0.2;
zoomIn.span.longitudeDelta = 0.2;
zoomIn.center.latitude = self.currentLocation.coordinate.latitude;//[[[m_CityMarkerArray objectAtIndex:0] valueForKey:@"lat"] doubleValue];
zoomIn.center.longitude = self.currentLocation.coordinate.longitude;//[[[m_CityMarkerArray objectAtIndex:0] valueForKey:@"lng"] doubleValue];
NSLog(@"%f LAT",self.currentLocation.coordinate.latitude);
[plotsMapView setRegion:zoomIn animated:YES];
}
該LAT返回0.0000。
但如果我在viewDidAppear中調用相同的方法,它工作正常。 我需要它在viewdidload中,因爲每次我回來查看。如果我調用viewDidAppear中的方法,我會將地圖重新加載到基本位置。
請幫忙! 謝謝!
謝謝!不知道爲什麼我想到它:| –
不客氣 – Neo