【发布时间】:2017-03-14 04:40:47
【问题描述】:
我在我的应用程序中使用谷歌地图。我在 info.plist 中设置了这个
隐私 - 使用时的位置使用说明
在我的代码(HomeScreen)中,我也在这样检查:
if (CLLocationManager.locationServicesEnabled())
{
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
} else{
let alertController = UIAlertController(title: "Oops !!" , message: "Location service seems to be disabled. Please enable from Settings -> Privacy ->LocationService.", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(defaultAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
但第一次安装应用程序时它不会请求许可。任何帮助都会有所帮助。
【问题讨论】:
-
你加了吗
在您的 .plist 文件中?为了能够检测您是否在开车,我们需要访问您的位置。 -
只需在您的 appdelegates.swift 文件中设置此代码
-
@HimanshuMoradiya AppDelagate 中要添加哪些代码??
标签: ios swift cllocationmanager locationmanager location-services