【发布时间】:2018-12-21 19:06:50
【问题描述】:
我有一个带有聊天功能的应用程序,它的设计是用 Objective-c 中的代码制作的,但是在对话中单词被破坏了。如何证明文本的合理性或为 UItextview 做某种自动换行?
我添加了一个 1 的 HypherationFactor,但问题没有解决,只是修复一些。我已经尝试了一段时间,但我无法做到。
_textView=[[UITextView alloc] init];
[_textView setTextContainerInset:UIEdgeInsetsZero];
_textView.textContainer.lineFragmentPadding = 0;
_textView.dataDetectorTypes=UIDataDetectorTypeAll;
_textView.font=[UIFont systemFontOfSize:17];
_textView.textColor=kTextColor;
_textView.layoutManager.hyphenationFactor = 1;
_textView.backgroundColor=[UIColor clearColor];
_textView.scrollEnabled=NO;
_textView.editable=NO;
我希望这些话被理解;例如:温度- 真的
【问题讨论】:
-
您好 Esteban,欢迎来到 StackOverflow。我已将您的代码复制并粘贴到一个测试项目中,仅向 _textview 和一些文本添加了一个框架,并且通过按音节截断单词,它可以按您的预期工作。你确定你没有在代码的其他地方搞乱它的换行管理吗?
标签: objective-c hyphenation word-break