相关疑难解决方法(0)

iPhone当前用户位置坐标显示为(0,0)

我正在尝试使用此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
Run Code Online (Sandbox Code Playgroud)

谁知道我在这里失踪了什么?在此先感谢您的帮助!

- (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);
}
Run Code Online (Sandbox Code Playgroud)

iphone coordinates mapkit

8
推荐指数
1
解决办法
3万
查看次数

标签 统计

coordinates ×1

iphone ×1

mapkit ×1