0

我到处寻找,但没有找到这个答案。

我正在构建一个 iOS 应用程序,它使用创建 CLPlacemark 的用户的位置(纬度 + 经度),并将街道 + 国家/地区发送到服务器并根据该位置返回响应。

现在服务器只能获取希伯来语值,CLPlacemark 值是根据用户的操作系统而变化的。

我可以为 CLPlacemark 类实例设置 const 语言吗?我希望 CLPlacemark 将返回希伯来语,无论用户的操作系统如何

这是我的代码:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    geoCoder = [[CLGeocoder alloc]init];
    [self.geoCoder reverseGeocodeLocation:locationManager.location completionHandler:
     ^(NSArray *placemarks, NSError *error) {

         CLPlacemark *placemark = [placemarks objectAtIndex:0];
         placemark.

         self.countryTextBox.text =[placemark.addressDictionary valueForKey:@"Country"];
         self.citiTextBox.text =[placemark.addressDictionary valueForKey:@"City"];
         self.streetTextBox.text =[placemark.addressDictionary valueForKey:@"Street"];
         self.zipCodLbl.text =[placemark.addressDictionary valueForKey:@"ZIP"];


         //NSLog(@"%@",placemark.addressDictionary);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"Country"]);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"City"]);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"Street"]);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"ZIP"]);

         [locationManager stopUpdatingLocation];
         [self.animationBar stopAnimating];



             }];

}

多谢。

伊丹

4

2 回答 2

4

经过几天的艰苦搜索,我终于解决了。

在视图中确实加载了只需添加这行代码:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"he"] forKey:@"AppleLanguages"];

如果这对某人有帮助-太好了!

于 2013-10-15T22:01:09.810 回答
0

弄乱用户的系统偏好是不好的做法!您应该改用:

NSLocale *yourLocal = [[NSLocale alloc] initWithLocaleIdentifier:@"de"];
[geoCoder reverseGeocodeLocation: preferredLocale:yourLocal completionHandler:
     ^(NSArray *placemarks, NSError *error) {

}];
于 2021-02-03T05:23:16.173 回答