UITextView:获取带有换行信息的文本 [英] UITextView : get text with wrap info

查看:103
本文介绍了UITextView:获取带有换行信息的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将UITextView中的文本及其换行信息获取到

Is it possible to get the text inside a UITextView with its wrap info.

所以在这种情况下.我将收到类似亲爱的StackOverFlow,\ n \ n您将创建我的..."之类的文本,而不再显示"\ n".我想在现在是我"之后获取换行符,如UITextView中所示.

So in this case. I will get text like "Dear StackOverFlow,\n\nYou make my..." with no more "\n". I would like to get a newline after "and now I", like shown in the UITextView.

推荐答案

在这里查看我的答案:

https://stackoverflow.com/a/13588322/341994

您要执行的操作正是Core Text为您执行的操作.实际上,Core Text是如何 UITextView知道如何包装文本.因此,您可以询问Core Text,就像UITextView一样,换行符在哪里.请参阅我的答案中的示例代码-它比您尝试做的要简单得多且更可靠.

What you are asking to do is exactly what Core Text does for you. Indeed, Core Text is how UITextView knows how to wrap text. So you can ask Core Text where the line breaks are, just as UITextView does. See the example code in my answer - it's a lot simpler and more reliable than what you're trying to do.

这篇关于UITextView:获取带有换行信息的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆