简体   繁体   English

如何在iOS的UILabel / UITextView中为中文显示多个屏幕尺寸的自动换行?

[英]How to handle word wrap in iOS' UILabel/UITextView for the Chinese language for multiple screen sizes?

I've an app that is being localized to Simplified Chinese . 我有一个本地化为简体Chinese的应用程序。 I've noticed that sometimes UILabels and UITextViews wrap characters but not entire words. 我注意到有时UILabelsUITextViews包装字符,但不能包装整个单词。

It seems a bit crazy to go through the Chinese language to manually point out line breaks for every single localized string for every single device size and orientation. 遍历Chinese为每个单个设备大小和方向的每个本地化字符串手动指出换行符似乎有点疯狂。

Is there a way to use NSLinguisticTagger to extract the words and tell UILabel to wrap based on what was tagged? 有没有一种方法可以使用NSLinguisticTagger提取单词并告诉UILabel根据标记的内容进行包装?

TextView.lineBreakMode = NSLineBreakMode.ByWordWrapping

TextView.sizeToFit()

Same for labels. 标签也一样。 It works for me not in Chinese but you can try 它对我来说不是中文,但您可以尝试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM