【发布时间】:2015-10-09 07:45:09
【问题描述】:
我使用核心定位来检测要在 URL 中使用的纬度和经度,但日志在两者中都打印了 0.00000
这是我的代码
mapViewcontroller.m
#import <CoreLocation/CoreLocation.h>
@interface mapsViewController () <CLLocationManagerDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *mapsweb;
@property(weak,nonatomic) CLLocationManager *locationmanager;
@end
@implementation mapsViewController
-(NSString *)getlat{
return [NSString stringWithFormat:@"%f",_locationmanager.location.coordinate.latitude];
}
-(NSString *)getlon{
return [NSString stringWithFormat:@"%f",_locationmanager.location.coordinate.longitude];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_locationmanager = [[CLLocationManager alloc]init];
_locationmanager.distanceFilter = kCLDistanceFilterNone;
_locationmanager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[_locationmanager startUpdatingLocation];
NSString *t1 = @"http://mymaps.com/clat/";
NSString *la = [self getlat];
NSString *t2 = @"/clng/";
NSString *lo = [self getlon];
NSLog(@"latitude is %@",[self getlat]);
NSLog(@"Longitude is %@",[self getlon]);
【问题讨论】:
标签: ios objective-c core-location