iOS, CoreLocation - Get users location when the app loads

南楼画角 提交于 2020-01-06 01:50:27

问题


I am trying to get my app to get the longitude and latitude of the users current position as soon as they load up the app. From here I can tell if they are a certain distance from a point, and call different functions based on this.

I can get it to work fine from viewDidLoad, but I don't want it to keep performing this every time said view is loaded. How would I (if possible) call this from the app delegates didFinishLaunchingWithOptions method?


回答1:


I think you're looking for CLLocationManager, which is the GPS implementation. It has no UI and runs in the background, but you don't invoke it from the PList, you implement a class. Find the "LocateMe" example project for the code.



来源:https://stackoverflow.com/questions/6683976/ios-corelocation-get-users-location-when-the-app-loads

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