gpt4 book ai didi

iphone - 如何使用 UITextInputMode

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:13:48 25 4
gpt4 key购买 nike

我需要创建一个检测键盘输入语言的方法。例如,当键盘语言是法语时会做某事,而当英语是英语时会做其他事情

我在网上搜索找到了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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com