作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 MKReverseGeocoder 的文档中,administrativeArea 属性为您提供用户当前所处的状态,并且在示例中提到它返回状态名称或其缩写。我想知道是否有人知道如何获取缩写而不是完整的州名...除了那个没有提到如何获取的简短示例之外,我找不到任何东西表明这甚至是一种可能性。
谢谢!
最佳答案
我还需要将 MKReverseGeocoder 中的 State 字段转换为两个字母的缩写,因此我创建了这个 plist:
https://github.com/djibouti33/US-State-Abbreviations
这是我的使用方法:
// in my initNSString *plistPath = [[NSBundle mainBundle] pathForResource:@"USStateAbbreviations" ofType:@"plist"];self.usStateAbbreviations = [[NSDictionary alloc] initWithContentsOfFile:plistPath];// MKReverseGeocoder delegate method- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { ... NSString *state = [address objectForKey:@"State"]; NSString *stateAbbreviation = [self.usStateAbbreviations objectForKey:[state uppercaseString]]; NSString *stateTarget = state; if (stateAbbreviation) { stateTarget = stateAbbreviation; } ...}
关于iPhone -- MKReverseGeocoder.adminstrativeArea -- 获取状态缩写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2518381/
在 MKReverseGeocoder 的文档中,administrativeArea 属性为您提供用户当前所处的状态,并且在示例中提到它返回状态名称或其缩写。我想知道是否有人知道如何获取缩写而不是完
我是一名优秀的程序员,十分优秀!