- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我需要创建一个检测键盘输入语言的方法。例如,当键盘语言是法语时会做某事,而当英语是英语时会做其他事情
我在网上搜索找到了UITextInputMode
但是我不知道怎么用,如果你能帮助我,我将不胜感激。谢谢
最佳答案
很简单,你可以这样做:
UITextInputMode *textInput = [UITextInputMode currentInputMode];
NSString *primaryLanguage = textInput.primaryLanguage;
NSLog(@"Current text input is: %@", primaryLanguage);
如 Apple 文档中所述,“此属性的值是 BCP 47 语言代码,例如“es”、“en-US”或“fr-CA””。。 p>
如果需要通知更改,请将 Controller 添加为 UITextInputCurrentInputModeDidChangeNotification
的观察者
关于iphone - 如何使用 UITextInputMode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12280606/
我需要创建一个检测键盘输入语言的方法。例如,当键盘语言是法语时会做某事,而当英语是英语时会做其他事情 我在网上搜索找到了UITextInputMode但是我不知道怎么用,如果你能帮助我,我将不胜感激。
在我们的应用中,我们想要检测当前的键盘语言。例如,如果用户在 Settings->General->Keyboard->Keyboards 下设置了多语言键盘,我们想知道他们输入的是什么语言,并在更改
我一直在努力快速解决这个问题 iPhone: Change Keyboard language programmatically但我发现了一些我不知道如何解决的问题, 此方法使我的应用程序崩溃 UIT
我想在 Swift 2 中获取 UITextInputMode,但 UITextInputMode.activeInputModes() 崩溃了。 let x = UITextInputMod
我是一名优秀的程序员,十分优秀!