cllocationmanager を使用して現在の場所を取得しようとしています。
問題:
デリゲート メソッド
-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
ビューdidappearの後に常に実行されます。viewDidLoadでstartupdatingLocation. そして、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 で同じメソッドを呼び出すと、正常に動作します。また、viewDidAppear でメソッドを呼び出すと、view.I に戻るたびにマップをベースの場所にリロードするため、viewdidload でそれが必要です。
助けてください!ありがとう!