ios getting my location regularly and setting button to get my location - Google Map not working

核能气质少年 提交于 2019-11-28 13:08:49

Did your - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ get called?

If not, you need to make sure your MapViewController implements the CLLocationDelegate. (Ex: @interface ViewController : UIViewController<CLLocationManagerDelegate> in your MapViewController.h file)

You can try this working example from GitHub, or the code snippet from this Gist.

Also, you should test it in your real device, otherwise you have to simulate a location in your XCode simulator (see image below, but it might not always work).

You have to add NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription to your info.plist file (note: don't rename or change the extension of the info.plist file, the extension has to be .plist):

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