iPhone:mapView.showUserLocation。 VS位置更新函数
我正在开发一个基于位置的应用程序,我设置了一个地图视图来显示用户位置(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您可能会同时使用 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.
您拥有 MKMapView 集的
showsUserLocation
属性(该属性可在 Interface Builder 中编辑)。来自其 文档:
You have the
showsUserLocation
property of your MKMapView set (this property is editable in Interface Builder).From its documentation: