iPhone: mapView.showUserLocation. VS locationUpdate function

↘锁芯ラ 提交于 2019-12-23 05:07:12

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2071484/iphone-mapview-showuserlocation-vs-locationupdate-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!