【发布时间】:2012-01-10 19:45:19
【问题描述】:
我的 iphone 应用程序应该根据用户的纬度和经度来解析地址。 reverseGeocodeLocation 工作正常,但结果是英文的。
有没有办法将结果本地化为其他语言?
在苹果或其他任何地方都找不到任何有关它的信息。
我使用的代码是:
CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];
CLLocation *location = [[[CLLocation alloc]
initWithLatitude:coord.latitude longitude:coord.longitude] autorelease];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
if (error){
NSLog(@"Geocode failed with error: %@", error);
[self displayError:error];
return;
}
if(placemarks && placemarks.count > 0)
{
//do something
CLPlacemark *topResult = [placemarks objectAtIndex:0];
NSString *addressTxt = [NSString stringWithFormat:@"%@ %@,%@ %@",
[topResult subThoroughfare],[topResult thoroughfare],
[topResult locality], [topResult administrativeArea]];
}
}
【问题讨论】:
-
CLGeocoder 基于 google geocoder,如果在 URL 参数中设置了语言选项,则可以生成本地化结果。我使用 google api,我返回的结果似乎已本地化为其他语言。这可能很明显,但是您是否将设备的语言设置为英语以外的语言?你还试过什么?
-
是的!它改变了语言,但问题仍然存在,是否可以将结果强制转换为特定语言?
-
从文档来看,我不这么认为。如果您在几个小时内没有收到更完整的答案,我将向您展示一些可能对您有所帮助的代码。不过,我面前没有它。
-
@user513790,你有没有得到关于如何将结果强制转换为特定语言的解决方案?对我们来说,它应该总是用英文吗?根据我目前的研究,这似乎是不可能的。
标签: iphone ios xcode clgeocoder