我很難找到設備的高度,我需要在我的應用程序中顯示高度我該怎麼做? 我已經試過了:如何獲得ios 8當前的高度?
var locationManager:CLLocationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager = CLLocationManager()
locationManager.requestWhenInUseAuthorization()
self.locationManager.delegate = self
self.locationManager.distanceFilter = kCLDistanceFilterNone
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.startUpdatingLocation()
}
func locationManager(manager: CLLocationManager!, didUpdateToLocation newLocation: CLLocation!, fromLocation oldLocation: CLLocation!) {
var alt = newLocation.altitude
print("\(alt)")
manager.stopUpdatingLocation()
}
沒有露面....
您是否在'info.plist'中添加了'NSLocationAlwaysUsageDescription'鍵? – WMios
你在你的info.plist中包含了「NSLocationAlwaysUsageDescription'鍵嗎? – AtWork
實際上OP是要求使用授權,所以他需要一個NSLocationInUseDescription,或者任何正在使用的版本。 –