即时更改 iOS 应用程序的语言 [英] Change iOS app's language on the fly

查看:43
本文介绍了即时更改 iOS 应用程序的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 iOS 应用程序,我希望用户能够在其中更改 UI 语言,而不受 iPhone 或 iPad 语言的影响.问题是,如何在语言更改时为当前显示的视图重新加载适当的 NIB 文件,以及如何加载适当的 .strings 文件以便 NSLocalizedString 正常工作?

I'm writing an iOS app, where I want the user to be able to change the UI language independent of the iPhone's or iPad's language. The question is, how do I reload the appropriate NIB file for the currently displayed view when the language changes and how do I load the appropriate .strings file so that NSLocalizedString works appropriately?

推荐答案

这应该可以解决问题,假设 de 是用户选择的新语言.还要确保您正在重新启动当前视图.

This should do the trick, assuming that de is the new language selected by the user. Also assure that you are reinitiating the current view.

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

这篇关于即时更改 iOS 应用程序的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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