H.N. H.N. - 1 year ago 86
Swift Question

Stop updating location when view (map) is not showing

I have an app with a map loaded immediately after the app starts.
Now I have some views in the app.
WHat I'd like to do is, whene I leave my mapview, into another view, I'd like the map to stop updating self location and than, only start updating again self location, when I come back to that map view.
(self location = user current location).

Anyone can tell me how to do that please?


Rob Rob
Answer Source

You can use locationM.stopUpdatingLocation()

Start updating location

 override func viewDidAppear(_ animated: Bool) {



And Stop

override func viewWillDisappear(_ animated: Bool) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download