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 应用程序的首选语言
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
