【发布时间】:2012-12-20 22:45:46
【问题描述】:
我使用此代码通过反向地理位置获取用户的完整地址。有人可以建议我从中获取邮政编码或邮政编码的方法吗?
//Geocoding Block
[self.geoCoder reverseGeocodeLocation: locationManager.location completionHandler:
^(NSArray *placemarks, NSError *error) {
//Get nearby address
CLPlacemark *placemark = [placemarks objectAtIndex:0];
//String to hold address
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
//Print the location to console
NSLog(@"I am currently at %@",locatedAt);
//Set the label text to current location
[locationLabel setText:locatedAt];
}];
【问题讨论】:
-
你检查过
placemark.addressDictionary里面的内容吗?我想有一个邮政编码的钥匙。 -
在 Apple Dev developer.apple.com/library/IOs/#documentation/CoreLocation/… 上有一个文件存在,但我缺乏适当的文件。它应该是 placemark.postalCode....
-
iOSRider 在这个问题中有一个答案,它显示了如何获取邮政编码:stackoverflow.com/q/5058798/558933
-
@RoboticCat 有必要投吗?
-
不确定?上面的链接不能正常工作。
标签: objective-c ios geolocation reverse-geocoding