我的应用程序是基于地理定位的应用程序,每个表视图中的条目都有条目的位置。奇怪的是,当用户来自美国以外的地方时,位置是用他们的语言写的。例如,有一个来自越南的用户,地址是用越南语写的。我使用像下面这样的reverseGeocodeLocation检索条目位置的地址。有办法只用英语取得成绩吗?我在其他堆叠溢出问题中尝试了这些代码,但没有起作用。
我第一次用Parse获得地理位置。我不需要这样做,但我只是决定这么做。
PFGeoPoint.geoPointForCurrentLocationInBackground {
(geoPoint: PFGeoPoint?, error: NSError?) -> Void in
var location = CLLocation(latitude: GlobalVariable.userLocation!.latitude, longitude: GlobalVariable.userLocation!.longitude)
CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in
if error != nil {
print("Reverse geocoder failed with error" + error!.localizedDescription, terminator: "")
return}
if placemarks!.count > 0 {
let pm = placemarks![0] as CLPlacemark
GlobalVariable.detailedLocation = "\(pm.subLocality)," + " \(pm.locality)," + " \(pm.ISOcountryCode)" }
发布于 2022-02-10 04:34:50
您可以将参数"preferredLocale“传递给特定语言。
let locale = Locale(identifier: "en_US")
CLGeocoder().reverseGeocodeLocation(location, preferredLocale: locale, completionHandler: {(placemarks, error) in
})
https://stackoverflow.com/questions/33743478
复制相似问题