안녕하세요 저는 현재 city.It 사용자를 찾으려면 mkreversegeocoder를 사용하고 있지만 다른 위치에서 시도 할 때 내 나라 (터키)의 자치구/구의 이름을 제공합니다. 예를 들어 "istanbul"가 정확하지만 내 나라에서 "susurluk"과 같은 도시 이름이 없습니다. 그것은 지구입니다. 왜 그것이 도시 이름 대신에 지구를 반환하는지 모르는가? 당신은 내가 게시 할하려는 경우 내 코드의MKReverseGeocoder는 도시가 아닌 도시를 반환합니까?
편집 1 :
-(void)viewDidLoad {
[super viewDidLoad];
manager=[[CLLocationManager alloc]init];
manager.delegate=self;
manager.desiredAccuracy=kCLLocationAccuracyBest;
[manager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)aManager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
MKReverseGeocoder *geocoder=[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];
geocoder.delegate=self;
[geocoder start];
[manager startUpdatingLocation];
}
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
NSDictionary * addressDict= [placemark addressDictionary];
//NSString *country = [addressDict objectForKey:@"Country"];
NSString *city = [addressDict objectForKey:@"City"];
//change the country name into en_US
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
NSString *country1 = [usLocale displayNameForKey: NSLocaleCountryCode value: countryCode];
[[NSUserDefaults standardUserDefaults] setObject:country1 forKey:@"country"];
[[NSUserDefaults standardUserDefaults] setObject:city forKey:@"city"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
if (error.code == kCLErrorHeadingFailure) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Problem"
message:@"Can't find the location!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alertView show];
[alertView release];
[manager stopUpdatingLocation];
}
}
-(void)locationManager:(CLLocationManager *)manager1 didFailWithError:(NSError *)error {
if (error.code != kCLErrorDenied) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Problem"
message:@"Can't find the location!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alertView show];
[alertView release];
[manager stopUpdatingLocation];
}
}
를 확인하시기 바랍니다 경우에서의 – Srinivas
일어나고 난 "발리 케시 르"도시와 지역에서 나는 때 "susurluk는"내가 볼 수있는 응용 프로그램을 사용하고 대신 저를 반환하는 susurluk 저를 반환 " balıkesir ". 그리고 두 개의 더 많은 지구"balıkesir ". –
초기화하는 동안 좌표 (위도/경도)를 전달하여 수행 할 작업 또는 다른 작업; – Srinivas