【发布时间】:2018-04-28 10:19:07
【问题描述】:
我在我的应用程序中使用了位置,它将在应用程序中获取纬度和经度,然后可以给我用户所在城市的名称 这个名字是英文的,但我想把它转换成波斯语 我找到了这种方法但这将在 iOS 11 中工作但我正在从 ios9 开发如何获得波斯语当前城市的打印? 这是我的代码
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if firstUpdate {
if let _latitude = locations.first?.coordinate.latitude {
if let _longitude = locations.first?.coordinate.longitude {
firstUpdate = false
self.locationManager.stopUpdatingLocation()
self.carregaDadosLocal(latitude: _latitude, longitude: _longitude)
let location = CLLocation(latitude: _latitude, longitude: _longitude)
if #available(iOS 11.0, *) {
CLGeocoder().reverseGeocodeLocation(location, preferredLocale: Locale(identifier: "fa_IR")) { (local, error) in
if (local?[0]) != nil {
print(local?[0].thoroughfare!)
print(local?[0].locality)
print(local?[0].location)
print(local?[0].subLocality)
}
}
} else {
// Fallback on earlier versions
}
}
}
}
}
【问题讨论】:
标签: ios swift4 cllocationmanager cllocation nslocalizedstring