我正在尝试使用此 viewDidLoad 方法获取用户当前的纬度和经度。生成的地图正确地指示了当前位置,但是 NSLog 始终显示:
2009-09-19 16:45:29.765 Mapper[671:207] user latitude = 0.000000
2009-09-19 16:45:29.772 Mapper[671:207] user longitude = 0.000000
有人知道我在这里想念什么吗?在此先感谢您的帮助!
- (void)viewDidLoad {
[super viewDidLoad];
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
[mapView setShowsUserLocation:YES];
CLLocation *userLoc = mapView.userLocation.location;
CLLocationCoordinate2D userCoordinate = userLoc.coordinate;
NSLog(@"user latitude = %f",userCoordinate.latitude);
NSLog(@"user longitude = %f",userCoordinate.longitude);
}