位置管理器在iPhone中找到当前位置后会重复查找当前位置吗?

发布于 2024-08-31 22:42:19 字数 697 浏览 3 评论 0原文

我是 iPhone 开发新手。我想知道 CLLocationManager 确定当前位置的工作过程。我已使用以下按钮事件代码来查找当前位置。

 self.locationManager = [[[CLLocationManager alloc] init] autorelease];

self.locationManager.delegate = self; // Tells the location manager to send updates to this object

[locationManager startUpdatingLocation];

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

我已经确定了纬度和经度值并加载了当前位置。

它运行良好。如果更新到新位置后,是否会再次调用获取当前位置?如果iPhone无法找到当前位置,是否会再次搜索当前位置?

我想知道这两种情况

  1. iPhone 是否确定当前位置。

  2. 如果 iPhone 无法确定当前位置。

I am new to iPhone development. I want to know the working process of the CLLocationManager in determining the current location. I have used the below code for the button event to find the current location.

 self.locationManager = [[[CLLocationManager alloc] init] autorelease];

self.locationManager.delegate = self; // Tells the location manager to send updates to this object

[locationManager startUpdatingLocation];

IN

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

I have determined the lat and long values and loaded the current location.

It is working fine. If after updating to the new location, will it be once again called to get the current location? If iPhone is not able to find the current location, will then once again search for current location?

I want to know for both cases

  1. If iPhone determines the current location.

  2. If iPhone doesn't able to determine the current location.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

捂风挽笑 2024-09-07 22:42:19

根据 CoreLocationManager 参考

定位服务返回一个
初始位置尽快
可能,返回缓存信息
当可用时。交付后
初始事件通知,
CLLocationManager 对象可以传递
附加事件(如果最少)
阈值距离(由下式指定)
distanceFilter 属性)是
超出或更准确的位置
值已确定。

这似乎表明(1)您可能会在它仍在尝试确定您当前位置时收到缓存的位置信息,(2)您可能会收到多个更新,因为它会更准确地确定位置。

According to the CoreLocationManager reference

The location service returns an
initial location as quickly as
possible, returning cached information
when available. After delivery of the
initial event notification, the
CLLocationManager object may deliver
additional events if the minimum
threshold distance (as specified by
the distanceFilter property) is
exceeded or a more accurate location
value is determined.

That seems to indicate that (1) you may received cached location information while it's still trying to determine your current location, (2) you may receive multiple updates as it determines the location more accurately.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文