gpt4 book ai didi

ios - 即使设置了更高的 gps 精度 (kCLLocationAccuracyThreeKilometers),位置也会更新

转载 作者:行者123 更新时间:2023-11-28 21:40:59 25 4
gpt4 key购买 nike

我正在开发一种导航应用程序。当应用程序启动时,我将 CLLocationManager 设置为最大可用精度 kCLLocationAccuracyThreeKilometers。基于该值,我预计在将近 3 公里后会有位置更新。但是,我每隔一秒就会更新一次位置 didUpdateLocations。例如,如果我将 distanceFilter 设置为 10(米),则不会每隔一秒调用一次 didUpdateLocations 委托(delegate)方法。 desiredAccuracy 属性的设置不足以“配置”GPS 频率吗?

- (void)initAndStartCoreLocation
{
self.locationManager = [[CLLocationManager alloc] init];

// self.locationManager.distanceFilter = 10;
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
self.locationManager.pausesLocationUpdatesAutomatically = YES;
self.locationManager.activityType = CLActivityTypeAutomotiveNavigation;

self.locationManager.delegate = self;

if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[self.locationManager requestAlwaysAuthorization];
}
[self.locationManager startUpdatingLocation];
}

最佳答案

来自 Apple 的编程指南:

And remember that specifying a value of kCLLocationAccuracyThreeKilometers doesn’t prevent the location service from returning better data. Most of the time, Core Location can return location data with an accuracy within a hundred meters or so.

这意味着 CLLocationManager 上的 desiredAccuracy 属性设置了您的应用将接收到的最低准确度。

根据您的需要,您应该使用 distanceFilter 属性或在 didUpdateLocations 方法中按时间(例如每 30 秒)过滤传入事件。

关于ios - 即使设置了更高的 gps 精度 (kCLLocationAccuracyThreeKilometers),位置也会更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32073119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com