Iphone 获取当前国家/地区时出错

Iphone 获取当前国家/地区时出错,iphone,locale,Iphone,Locale,我使用以下代码来获取当前国家/地区 NSLocale *locale = [NSLocale currentLocale]; NSString *countryCodes = [locale objectForKey:NSLocaleCountryCode]; NSString *countryName = [locale displayNameForKey:NSLocaleCountryCode value:countryCodes]; NSLog(@"%@",countryName); 我

我使用以下代码来获取当前国家/地区

NSLocale *locale = [NSLocale currentLocale];
NSString *countryCodes = [locale objectForKey:NSLocaleCountryCode];
NSString *countryName = [locale displayNameForKey:NSLocaleCountryCode value:countryCodes];
NSLog(@"%@",countryName);
我在阿联酋,但这是美国,我在我的iPod上测试,请帮助我如何获得当前国家

-(void)viewWillAppear:(BOOL)animated
{
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
    [super viewWillAppear:animated];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{
    MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];
    geoCoder.delegate = self;
    [geoCoder start];
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
    NSLog(@"Detail is:--> %@",placemark);

    NSString *strCountry = [NSString stringWithFormat:@"Current Cuntry %@",[placemark.addressDictionary objectForKey:@"Country"]];

    NSLog(@"label detail is:--> %@",strCountry);

    lblAddress.text = strCountry;
}

试试这段代码……这肯定会给你一个当前国家/地区的详细信息。

你是否在模拟器上测试?检查一下你的iPod设置(地区格式)。@Narayana如果我将地区格式更改为阿拉伯语(阿联酋),它会将语言转换为阿拉伯语