我想让我的程序在地图上显示用户的位置。它一开始工作,然后随机停止,所以我添加了下面的代码来尝试修复它,但我遇到了问题。提前致谢!位置权限检查和授权
override func viewDidLoad()
{
super.viewDidLoad()
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
if CLLocationManager.locationServicesEnabled()
{
let status: CLAuthorizationStatus = CLLocationManager.authorizationStatus()
if status == CLAuthorizationStatus.NotDetermined
{
locationManager.requestAlwaysAuthorization()
}
} else {
print("locationServices disenabled")
}
locationManager.startUpdatingLocation()
self.locationManager.startUpdatingLocation()
self.mapView.showsUserLocation = true
mapView.delegate = self
centerMapOnLocation(initialLocation)
addBoundry()
}
你有什么问题? – eMKa
我们需要更多关于您面临的问题的信息。另外我注意到有2个调用'locationManager'的'startUpdatingLocation'方法。 – tek3
您是否在info.plist中设置了必填字段? – Rikh