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