UITextView 自动换行在单词中间中断
我使用 UITextView
来呈现可能是一行或多行长的定义。当它确实经过一条车道时,如果经常在单词中间换行。
这是正常的吗?可以采取什么措施来防止这种情况发生?
I'm using a UITextView
to present definitions which may be one or more lines long. When it does go past a lane, if often wraps in the middle of a word.
Is this normal? What can be done to prevent this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
自动换行是 IOS UITextView 的默认设置,也是 Quuxplusone 在他的评论中提到的失败的唯一原因。
无论是
word wrap IS the default for IOS UITextView and the only reasons it fails Quuxplusone mentioned in his comment.
EITHER
当排除路径太靠近 UITextView 的边缘时,似乎会发生这种情况。在这个示例中伴随着这个tutorial 您会注意到,如果您运行该应用程序并选择“交互”选项卡,则当椭圆形放置在单词中央时连字符并自然断开,如果您将其拖到左侧边缘,然后单词会被强行破坏并支离破碎。但是,如果将椭圆形的一半拖离屏幕,则可以进行环绕。
因此,在处理椭圆形时,您可以使用离开左边缘的技巧,而在处理矩形时,不要太靠近边缘。对抗它就好了。
It appears that this can occur when exclusion paths are too close to the edge of the UITextView. In this example accompanying this tutorial you'll notice that if you run the app and select the Interaction tab that while the oval is placed centrally words hyphenate and break naturally, if you drag it to the left edge then words break forcibly and are fragmented. But if you drag the oval half off the screen then wrapping works.
So when working with ovals you can use the trick of going off the left edge, and with rectangles, just don't get too close to the edge. Being up against it is fine.
你可以这样做:
UITextview 具有启用滚动属性。所以文本字符限制并不重要。如果有更多文本,文本视图会使其可滚动。
或者
使文本视图高度动态化,获取字符串/文本高度并相应地设置文本视图的高度。
You can do it as :
UITextview having a property of enable scrolling. So the text characters limit doesn't matters. If there is more text, the textview make it scrollable.
OR
Make the textview height dynamic, get the string/text height and set the height of textview accordingly.