How to change the preferred language of an iPhone app in iOS 4(如何在 iOS 4 中更改 iPhone 应用程序的首选语言)
问题描述
已经讨论了更改 iPhone 应用程序的语言 许多 次,但我坚持这个:提供的解决方案需要重新启动应用程序才能使更改生效.但是你如何在 iPhone 4 上实现这一点呢?按主页"将应用程序发送到后台,然后单击应用程序图标将其返回.用户体验到好像重新启动了应用程序,并想知道为什么语言没有改变.感谢您的帮助.
Changing the language of an iPhone app has been discussed many times, but I'm stuck with this one: The provided solutions require the app to be restarted to make the changes take effect. But how do you achieve this on an iPhone 4? Pressing "home" sends the app to the background and clicking the app icon just brings it back. The user has experience as if the app had been restarted and wonders why the language hasn't changed. Thanks for your help.
推荐答案
您可以编写自己的替换 NSLocalizedString.在头文件中,执行类似
You could write your own replacement for NSLocalizedString. In the header file, do something like
#undef NSLocalizedString
#define NSLocalizedString(key, comment) MyLocalizedStringFunction(key)
在您的函数中,使用 NSBundle 加载正确的 .lproj 包,然后调用
In your function, load the correct .lproj bundle using NSBundle, then call
[bundle localizedStringForKey:key value:nil table:nil];
在它上面得到你想要的字符串.
on it to get the string you want.
我不知道这是否是最好的方法:我们不得不使用它,因为我们想要支持一种 iPhone 上不存在的语言,所以您的问题可能有一个更简单的解决方案.
I don't know if that's the best way: we had to use it because we wanted to support a language that didn't exist on the iPhone, so your problem may have a simpler solution.
这篇关于如何在 iOS 4 中更改 iPhone 应用程序的首选语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 iOS 4 中更改 iPhone 应用程序的首选语言


基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01