how to change Application language on run time using Two Button in iphone SDK?

前端 未结 7 1319
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 06:30

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 ta

7条回答
  •  半阙折子戏
    2020-12-17 07:06

    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"];
    

    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.

提交回复
热议问题