0
我在我的info.plst文件中包含了NSLocationWhenInUsageDescription
和NSLocationAlwaysUsageDescription
,我的代碼是這樣的。locationManager委託不工作
import UIKit
import MapKit
class LocationSelectorViewController: UIViewController,
UISearchBarDelegate, MKMapViewDelegate {
@IBOutlet weak var locationSearchBar: UISearchBar!
@IBOutlet weak var mapView: MKMapView!
var selectedLoc: String?
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.requestAlwaysAuthorization()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
locationManager.startUpdatingLocation()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func locationManager(manager: CLLocationManager, didupdateLocations locations: [CLLocation]) {
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
}
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
}
}
我覺得我沒有什麼錯,但它繼續顯示此錯誤
不能分配的類型「LocationSelectorViewController」價值型「CLLocationManagerDelegate?」
你能告訴我問題在哪裏嗎?