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

﹥>﹥吖頭↗ 提交于 2019-12-01 12:05:36

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.

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.

Ehren
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

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