我想讓我的程序在地圖上顯示用戶的位置。它一開始工作,然後隨機停止,所以我添加了下面的代碼來嘗試修復它,但我遇到了問題。提前致謝!位置權限檢查和授權
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