我使用CLGeocoder從經度/緯度解碼CLLocation來放置名稱。它工作正常。但是還有一件事讓我困擾。當我將設備設置語言爲英語,下面的代碼的結果:CLPlacemark.locality,如果設備語言不同,則值發生變化
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
/* We received the new location */
NSLog(@"Latitude = %f", newLocation.coordinate.latitude);
NSLog(@"Longitude = %f", newLocation.coordinate.longitude);
[self.geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray* placemarks, NSError* error){
MKPlacemark *placemarker = [placemarks objectAtIndex:0];
NSLog(@"%@",placemarker.locality);
}];
[self.locationManager stopUpdatingLocation];
}
以英文顯示,如:成都。
當我更改設備的語言對中國,
placemarker.locality
返回中國的字符值。
但我真正想要的是它總是會返回一個英文字符值(沒有中文字符值)。 我想這是有關語言環境的東西。任何人都可以幫忙嗎?謝謝。
試過這個解決方案,但它不適用於iOS 9或是因爲模擬器。讓我知道是否有人知道任何解決方法。 –
它也不適用於我.. @MohammadAshrafulKabir你有任何更新嗎? – Akshay
@Akshay沒有更新從我身邊 –