Getting Longitude/Latitude of the User When the viewDidLoad

后端 未结 5 608
故里飘歌
故里飘歌 2020-12-29 10:22

My purpose is to get the longitude/latitude of the user when the view is loaded and to store the values in two variables for later calculations. I don\'t need to track the u

5条回答
  •  感动是毒
    2020-12-29 10:48

    To get user's location even once you need to make locationManager to start updating locations (you did that) and implement delegate method that manager calls when location is retrieved - you can't get location from location manager immediately.

    If you don't want to track user location - just stop updating locations in that delegate method after location was fetched for the 1st time (and store it if you need it in future).

提交回复
热议问题