iPhone: mapView.showUserLocation. VS locationUpdate function
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?
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.
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.
精彩评论