2010-11-25 113 views
3

我使用该代码来设置的标签带,其中从一个标获得的通途,subThoroughfare,POSTALCODE,局部性,COUNTRYCODE一个位置字符串反向地理编码和本地化

locationString = [[NSString alloc] initWithFormat:@"%@%@ - %@ %@%@", 
        thoroughfare,subThoroughfare,postalCode, 
        locality,countryCode]; 

locationLabel.text = locationString; 

现在,我想根据当前的语言环境可视化该字符串。我是否为每个我感兴趣的区域指定一个字符串格式,或者有更简单的方法来获取它?

感谢, 弗兰

+0

好的,谢谢。这个问题的任何想法? – Sefran2 2010-11-26 16:23:58

回答

0

地标对象的addressDictionary财产应在部分解决其FormattedAddressLines阵列的问题。

1

你可以用下面的函数

-(void) setLocation:(NSString *)latitude withLongitude:(NSString *)longitude { 
    CLGeocoder *geocoder = [[CLGeocoder alloc] init]; 
    CLLocation *location = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] longitude:    
    longitude doubleValue]]; 
     CLGeocodeCompletionHandler completionHandler =^(NSArray *placemarks, NSError *error){ 
       if (error){ 
         NSLog(@"error in fetching location <%@>",error); 
        return ; 
       } 
       if (placemarks && placemarks.count >0){ 
        CLPlacemark *mark = [placemarks objectAtIndex:0]; 
         NSString *addresstring = [[mark addressDictionary] objectForKey:@"FormattedAddressLines"] componentsJoinedByString:@","]; 
      *//fetched addressDictionary for key FormattedAddressLines* 

      }