How can I change the language of the displayed UIKeyboard from within my iPhone app?

浪尽此生 提交于 2019-12-01 09:45:16

问题


Within my iPhone application, I'd like to change the language of the displayed UIKeyboard. How can I do this?


回答1:


From the iPhone Application Programming Guide:

Depending on the needs of your program and the user’s preferred language, the system might display one of several different keyboards. Although your application cannot control the user’s preferred language (and thus the keyboard’s input method), it can control attributes of the keyboard that indicate its intended use, such as the configuration of any special keys and its behaviors.

[...]

To facilitate the language preferences of different users, iPhone OS also supports different input methods and keyboard layouts for different languages, some of which are shown in Figure 5-4. The input method and layout for the keyboard is determined by the user’s language preferences.

So it appears there's no way to bring up a keyboard of a different language than the user's preference.




回答2:


really cant do it programatically, the user must have that keyboard enabled and then they can get to it, you can maybe tell the user they require a non english keyboard in an alert view or something like that.




回答3:


NSString *iso631Code = @"zh";

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:iso631Code] forKey:@"AppleLanguages"];

gives me a Chinese (pinyin) keyboard (you can even dynamically switch between say @"zh", @"fr", @"en" without having to restart).

see also How to force NSLocalizedString to use a specific language



来源:https://stackoverflow.com/questions/1784935/how-can-i-change-the-language-of-the-displayed-uikeyboard-from-within-my-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!