ios - CLLocationManager说我在伦敦

标签 ios geolocation cllocationmanager

几天以来我就遇到了这个问题...无法找出原因,但是这种方法:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{

    long now = [[[NSDate alloc] init] timeIntervalSince1970];

    //avoid cached locations
    if(abs([newLocation.timestamp timeIntervalSinceNow]) > 15.0f)
    {
        return;
    }
    //avoid more the 1KM location
    if(newLocation.horizontalAccuracy > 1000 || newLocation.horizontalAccuracy < 0)
    {
        return;
    }
    //if we already located, no need to go any further
    if(alreadyLocated)
    {
        [locationManager stopUpdatingLocation];
        return;
    }
    alreadyLocated = YES;
    [self stopLocating];
    [[SPPreferenceHandler getInstance] setValue:[NSNumber numberWithLong:now] forKey:LAST_LOCATION_UPDATE];
    CLLocation *currentLocation = newLocation;
    if (currentLocation != nil) {
        //blabla some code
    }
}

总是说我在伦敦:

当前位置的打印说明:<+ 51.50998000,-0.13370000> ...

我不知道发生了什么事...
有关信息,我正在iPhone 5上进行测试,测试将其插入Mac并拔出...仍然存在相同的问题。

如果你们能帮助我!那简直太好了 !

最佳答案

好的,所以这是为了防止某些人像我一样被此类错误困扰:

确保转到产品->方案->编辑,然后取消选中“允许位置模拟”

关于ios - CLLocationManager说我在伦敦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23872421/

相关文章:

ios - CLLocationManager startUpdatingLocation 未调用 locationManager :didUpdateLocations: or locationManager:didFailWithError:

ios - 根据单元格中的内容自动更改单元格内容 - Xcode 9.2 Swift 4

ios - 导航栏下方的空白

PHP MySql 和地理定位

database - 地理定位数据库是如何组装的?

ios - iOS 中的 Swift 中使用 "locations array"或 "manager.location.coordinate"哪一个来获取用户位置?

ios - 将时间从字符串转换为日期仅在模拟器上崩溃

ios - iOS9 中具有自适应布局的 Center 4 图像

ruby-on-rails - Ruby 地理定位 Gem/插件

ios - Parse.com 获取附近的用户