0
我剛開始使用地圖和位置。我已經添加了所需的代碼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 ")
}
}
沒有輸出仍然@Sandeep庫馬爾 –
你正在測試的設備上還是模擬器? –
模擬器@Sandeep Kumar –