我很难找到设备的高度,我需要在我的应用程序中显示高度我该怎么做? 我已经试过了:如何获得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,或者任何正在使用的版本。 –