用ios自带的定位功能,怎么定位到香港去了?我在内地
//定位方法
-(void)locate{
if ([CLLocationManager locationServicesEnabled]) {
self.myLocation = [[CLLocationManager alloc]init];
self.myLocation.delegate = self;
[self.myLocation setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
if (SYSTEMVERSION >= 8.0) {
[ self.myLocation requestAlwaysAuthorization];
}
//使用中授权
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized) {
[self.myLocation startUpdatingLocation];
}else{
[Util showAlertView:@"您还没有授权本应用使用定位服务,请到 设置 > 隐私 > 位置 > 定位服务 中授权" ];
}
}else{
[Util showAlertView:@"请开启定位:设置 > 隐私 > 位置 > 定位服务"];
}
}
//定位成功回调方法
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
[self.myLocation stopUpdatingLocation];
_lastLocation= [locations lastObject];
NSLog(@"latitude:%f",_lastLocation.coordinate.latitude);
NSLog(@"longitude:%f",_lastLocation.coordinate.longitude);
[_tableView.header beginRefreshing];
}
输出的结果:
latitude:22.284681
longitude:114.158177
而且在设置的定位服务中看不到我的app,这是怎么回事?
天空的荣耀
9 years, 5 months ago