xcode 6.1 iOS 8.1 NSLocale displayNameForKey NSLocaleIdentifier返回nil [英] xcode 6.1 iOS 8.1 NSLocale displayNameForKey NSLocaleIdentifier return nil
问题描述
- (NSString *)countryNameByCode:(NSString*)countryCode
{
NSString *identifier = [NSLocale localeIdentifierFromComponents:@{NSLocaleCountryCode: countryCode}];
NSString *countryName = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:identifier];
return countryName;
}
这返回了nil
.为什么?
推荐答案
这是仅适用于iOS 8.1 simulator 的Apple已知问题-在8.1设备上不可重现.请参见Xcode 6.1发行说明中的以下问题描述:
This is a known Apple issue for iOS 8.1 simulator only - not reproducible on 8.1 devices. See below issue description from Xcode 6.1 release notes:
本地化和键盘设置(包括第三方键盘)为 iOS中的Safari,地图和开发人员应用未正确兑现 8.1模拟器. [NSLocale currentLocale]返回en_US ,并且只有英文和Emoji键盘可用. (18418630,18512161).
Localization and Keyboard settings (including 3rd party keyboards) are not correctly honored by Safari, Maps, and developer apps in the iOS 8.1 Simulator. [NSLocale currentLocale] returns en_US and only the English and Emoji keyboards are available. (18418630, 18512161).
See Xcode 6.1 Release Notes for more details.
这篇关于xcode 6.1 iOS 8.1 NSLocale displayNameForKey NSLocaleIdentifier返回nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!