【问题标题】:iOS Get Language of Keyboard [duplicate]iOS获取键盘语言[重复]
【发布时间】:2014-10-23 02:52:55
【问题描述】:

我们能否得到用户正在使用的current keyboardlanguage.. 即查看用户使用的是英文键盘还是中文键盘或其他语言……?

我可以获取设备的语言,但我必须获取用户的输入语言。

提前致谢。

【问题讨论】:

标签: ios objective-c uikeyboard


【解决方案1】:

你可以像下面这样

[UITextInputMode currentInputMode].primaryLanguage

【讨论】:

    【解决方案2】:

    从此 documentation,您可以进一步使用NSLocale 获取语言的显示名称。

    NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:[YOUR_TEXTFIELD_INSTANCE textInputMode].primaryLanguage];
        NSLog(@"%@", [locale displayNameForKey:NSLocaleIdentifier value:[YOUR_TEXTFIELD_INSTANCE textInputMode].primaryLanguage]);
    

    如果主要语言是En-US,NSLog 会打印“英语(美国)”。

    注意:currentInputMode 在 iOS 7.0 中已被弃用。考虑像上面一样使用textInputMode

    【讨论】:

      猜你喜欢
      • 2016-08-11
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 2016-01-27
      • 1970-01-01
      • 2011-08-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多