【发布时间】:2013-04-11 12:38:23
【问题描述】:
我正在尝试按位置获取当前的经纬度,但我得到的都是 0.0000,我正在使用以下代码
(CLLocationCoordinate2D) getLocation{
CLLocationManager *locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
return coordinate;
}
并称之为使用:
CLLocationCoordinate2D coordinate = [self getLocation];
NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];
NSLog(@"*dLatitude : %@", latitude);
NSLog(@"*dLongitude : %@",longitude);
我还在项目中添加了核心定位。 请给我建议。
【问题讨论】:
-
如果您想设置您的当前位置,请查看stackoverflow.com/questions/214416/…