Change language of the ios application

前端 未结 1 1357
天涯浪人
天涯浪人 2020-12-29 17:52

I\'ve put my app settings into iPhone Settings panel. I want to switch between languages independently of the iPhone system language. Is it possible? I\'m using this advice:

相关标签:
1条回答
  • 2020-12-29 18:22

    The key is to override the NSUserDefaults language key before UIApplicationMain() is called in your main() function in main.m. Try something like this in your main() function:

    // use whatever language/locale id you want to override
    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"de_DE", nil]
                                              forKey:@"AppleLanguages"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    
    0 讨论(0)
提交回复
热议问题