iPhone:mapView.showUserLocation。 VS位置更新函数

发布于 2024-08-17 23:18:05 字数 292 浏览 5 评论 0原文

我正在开发一个基于位置的应用程序,我设置了一个地图视图来显示用户位置(mapView.showUserLocation);我还有一个 locationUpdate 函数来检索当前位置的纬度/经度:

(void)locationUpdate:(CLLocation *)location{} 

在调用函数 stopUpdatingLocation 停止更新位置后,地图视图(蓝色球)继续更新我的位置...

换句话说:是否还有另一个 locationUpdate 函数从地图视图中自动调用?

I'm developing on an app that is location-based, I have a mapView set to show the user location (mapView.showUserLocation); I also have a locationUpdate function to retrieve lat/long of current position:

(void)locationUpdate:(CLLocation *)location{} 

After I call the function stopUpdatingLocation to stop the update location, the mapview (blue ball) continues to update my location...

In other word: is there another locationUpdate function is called automatically from the mapview?

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

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

发布评论

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

评论(2

夏末 2024-08-24 23:18:05

我认为您可能会同时使用 MKMapView 和 CLLocationManager。 (void)locationUpdate 当 CLLocationManager 获取到位置时执行。 MKMapView独立使用GPS设备并自行更新。

您应该停止使用 showUserLocation 并使用 CLLocationManager 获取位置,然后使用 MKMapView 来呈现它。

I think you might use both MKMapView and CLLocationManager. (void)locationUpdate is executed when there's a position obtained by CLLocationManager. MKMapView uses GPS device independently and updates itself.

You should stop using showUserLocation and use CLLocationManager to obtain location, then MKMapView to present it.

別甾虛僞 2024-08-24 23:18:05

您拥有 MKMapView 集的 showsUserLocation 属性(该属性可在 Interface Builder 中编辑)。

来自其 文档

将此属性设置为 YES 会导致
使用核心位置的地图视图
寻找当前的框架
地点。只要这个属性是
是的,地图视图继续跟踪
用户的位置并更新它
定期。

You have the showsUserLocation property of your MKMapView set (this property is editable in Interface Builder).

From its documentation:

Setting this property to YES causes
the map view to use the Core Location
framework to find the current
location. As long as this property is
YES, the map view continues to track
the user’s location and update it
periodically.

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