gpt4 book ai didi

ios - 从 reverseGeocodeLocation 仅返回英文地址

转载 作者:行者123 更新时间:2023-12-05 07:52:23 27 4
gpt4 key购买 nike

我的应用程序是基于地理位置的应用程序,tableview 中的每个条目都有条目的位置。我发现奇怪的是,当用户来自美国以外时,该位置是用他们的语言写的。例如,有一位来自越南的用户,地址是用越南语写的。我正在使用如下所示的 reverseGeocodeLocation 来检索条目位置的地址。有没有办法只用英语获得结果?我在其他 stackoverflow 问题中尝试了代码,但没有用。

我首先使用 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)" }

最佳答案

您可以将参数“preferredLocale”传递给特定语言

let locale = Locale(identifier: "en_US")
CLGeocoder().reverseGeocodeLocation(location, preferredLocale: locale, completionHandler: {(placemarks, error) in

})

关于ios - 从 reverseGeocodeLocation 仅返回英文地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33743478/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com