如何使用 iphone SDK 中的两个按钮在运行时更改应用程序语言? [英] how to change Application language on run time using Two Button in iphone SDK?

查看:8
本文介绍了如何使用 iphone SDK 中的两个按钮在运行时更改应用程序语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 ios 平台上构建一个项目,并希望在此应用程序中使用两种语言并且还想要.用户可以在运行时更改语言假设我们可以使用两个语言按钮按钮 1 用于英语,按钮 2 用于德语,用户可以随时使用这些按钮更改应用程序语言.任何帮助或教程

i am building up a project in ios platform and want to use two language in this application and also want . the user can change the language on Runtime suppose we can take two language button button 1 for english and button 2 for german and the user can change the application language at any time by using these button . any help or tutorials

提前致谢

推荐答案

假设您已为英语和德语创建本地化,您的应用将使用设置中选择的语言(这是首选选项).

Assuming that you have created localizations for English and German, your app will use the language selected in Settings (this is the preferred option).

如果您想直接从应用程序设置语言:

If you want to set the language directly from your application:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", nil] forKey:@"AppleLanguages"];

只会将您的应用程序的语言设置为英语(对于德语,我假设键是de").您还应该:

will set the language for your application only to English (for German, I assume the key is "de"). You should also:

[[NSUserDefaults standardUserDefaults] synchronize];

这在您的应用程序重新启动之前不会生效.

This will not take effect until your application restarts.

这篇关于如何使用 iphone SDK 中的两个按钮在运行时更改应用程序语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆