【问题标题】:Is it possible to detect the current keyboard input method on the iPhone?是否可以检测到 iPhone 上当前的键盘输入法?
【发布时间】:2011-04-21 02:33:48
【问题描述】:

我想知道用户正在输入的当前输入法,例如 En(英语)、德语、中文等...也许键盘类型是我所追求的,但 Apple doc 中的文档似乎对此主题有限.

谢谢!

管理 iPhone 键盘 http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

【问题讨论】:

标签: iphone objective-c


【解决方案1】:

在 iOS4.2 中有一个新类 UITextInputMode 正是你想要的。 (糟糕,这仍在保密协议下。如果您没有 iOS 开发中心帐户,请不要阅读此答案;))

您可以查询当前模式(英语、法语、日语等)或在更改时获取通知(键盘语言更改)

UITextInputMode documentation (requires log in)

【讨论】:

  • +1 谢谢!这就是我正在寻找的东西,但不幸的是,它需要 4 次迭代才能完成,如果仅限于 4.2 对我来说有点用处
【解决方案2】:

currentInputMode 自 iOS7 起已弃用,请小心。

currentInputMode

返回一个代表当前文本输入模式的实例。 (在 iOS 7.0 中已弃用。)

【讨论】:

【解决方案3】:

这里有教程

http://www.switchonthecode.com/tutorials/a-simple-localization-example-for-the-iphone

NSLocale* curentLocale = [NSLocale currentLocale];

【讨论】:

  • 在任何本地,您都可以拥有多个输入法。这在亚洲语言中很常见,例如中文输入法:繁体、简体、拼音、德语等。
猜你喜欢
  • 1970-01-01
  • 2010-11-27
  • 2022-12-05
  • 2014-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-01
  • 2012-09-10
相关资源
最近更新 更多