使用按钮更改iphone应用程序语言,无需重新启动应用程序 [英] Change iphone app language with buttons and without restart of the app
问题描述
我想更改应用的语言。目前我正在以下列方式进行。
我有两个按钮可以更改NSUserDefaults中的语言。但在此之前影响我的应用程序我需要重新启动它。
I want to change the language of my app. At the moment I am doing it at the following way. I have two buttons which are change the languages in NSUserDefaults. But before this affects my app I need to restart it.
这是我的代码。
- (IBAction)changeDutch:(id)sender {
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"nl", @"en", nil] forKey:@"AppleLanguages"];
}
- (IBAction)changeEnglish:(id)sender {
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", @"nl", nil] forKey:@"AppleLanguages"];
}
这很好用。但我不希望每次都重启我的应用程序。谁能告诉我怎么做?
This works fine. But I don't want every time to restart my app. Can anyone tell me how to do that?
亲切的问候!
推荐答案
查看HMLocalization: https://github.com/HeshamMegid/HMLocalization
Check out HMLocalization: https://github.com/HeshamMegid/HMLocalization
它是默认本地化框架的替代品。它有一个演示,演示如何在不重新启动应用程序的情况下更改语言。
It's a replacement for the default localisation framework. It has a demo showing how to change language without having to restart the app.
这篇关于使用按钮更改iphone应用程序语言,无需重新启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!