菜鸟教程小白 发表于 2022-12-12 22:10:56

objective-c - UILocalizedIndexedCollat​​ion 不显示汉字


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

<pre>[ sectionIndexTitles]</pre>

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

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

<ol>
<li>英语 - en.lproj</li>
<li>西类牙语 - es.lproj</li>
<li>俄语 - ru.lproj</li>
<li>中文 - zh_Hans.lproj</li>
</ol>

<p>谁能帮我找出问题。</p>

<p>谢谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>苹果 <a href="http://developer.apple.com/library/ios/#qa/qa1739/_index.html#//apple_ref/doc/uid/DTS40011151" rel="noreferrer noopener nofollow">http://developer.apple.com/library/ios/#qa/qa1739/_index.html#//apple_ref/doc/uid/DTS40011151</a> </p>

<blockquote>
<p>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 &#34;A&#34;
through &#34;Z&#34; and &#34;#&#34; sections, even though UILocalizedIndexedCollation
is capable of providing Traditional Chinese section titles and sorting
row data into these sections.</p>

<p>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&#39;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</p>
</blockquote></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - UILocalizedIndexedCollat​​ion 不显示汉字,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/11508996/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/11508996/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - UILocalizedIndexedCollat​​ion 不显示汉字