开发者社区> 问答> 正文

为什么用ios自带的定位功能,定位到香港去了?我在内地 啊!

用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,这是怎么回事?
补充:有时候还是会定位到香港,但是重启一下就没问题了,不知道是怎么回事

展开
收起
爵霸 2016-03-11 11:16:24 2974 0
1 条回答
写回答
取消 提交回答
  • 你的定位要先授权,你应该少了那步吧,有系统提醒你打开吗?

    2019-07-17 18:58:45
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载