OGeek|极客世界-中国程序员成长平台

标题: objective-c - UILocalizedIndexedCollat​​ion 不显示汉字 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 22:10
标题: objective-c - UILocalizedIndexedCollat​​ion 不显示汉字

在我的 iphone 应用程序中,我使用英语、西类牙语、俄语和中文本地化。本地化适用于所有本地化字符串。但是 UILocalizedIndexedCollat​​ion 不适用于中文。当我将设备语言更改为英语、西类牙语和俄语时,表格索引显示正确。但是当我将设备语言设置为中文时,我得到的是英文的表索引,同时本地化的字符串本身就是中文的。

[[UILocalizedIndexedCollat​​ion currentCollat​​ion] sectionIndexTitles]

上面的代码为中文本地化返回一个英文字母数组,而它为其他三种语言(英语、西类牙语和俄语)返回正确的字符数组。

我正在使用以下 .lproj 文件进行本地化

  1. 英语 - en.lproj
  2. 西类牙语 - es.lproj
  3. 俄语 - ru.lproj
  4. 中文 - zh_Hans.lproj

谁能帮我找出问题。

谢谢。



Best Answer-推荐答案


苹果 http://developer.apple.com/library/ios/#qa/qa1739/_index.html#//apple_ref/doc/uid/DTS40011151

The localization data that UILocalizedIndexedCollation uses at run-time will be based on the localization that your application bundle is using. If your application only supports English, and the device is set to use Traditional Chinese, UILocalizedIndexedCollation will only show English section titles and sort rows into the "A" through "Z" and "#" sections, even though UILocalizedIndexedCollation is capable of providing Traditional Chinese section titles and sorting row data into these sections.

To address this, your application bundle must properly declare support for the languages you want UILocalizedIndexedCollation to support. You can add localizations to your application bundle either by adding the appropriate .lproj folders, or by specifying supported localizations in your CFBundleLocalizations key in your application's info.plist file. Note that the former approach is preferred, as it easier to maintain if localized resources need to be added to your application in the future

关于objective-c - UILocalizedIndexedCollat​​ion 不显示汉字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11508996/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4