我刚开始使用地图和地点。我已将所需的代码添加到info.plist中(在<dict>
之后):
<key>NSLocationAlwaysUsageDescription</key>
<string>Can we use your location?</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Can we use your location?</string>
但是我无法调用函数,因此我没有任何输出
import UIKit
import CoreLocation
class ViewController: UIViewController , CLLocationManagerDelegate {
var locationManeger = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManeger.delegate = self
locationManeger.requestWhenInUseAuthorization()
locationManeger.startUpdatingLocation()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) {
print("got the location ")
}
}