在UITextView中检测换行 [英] Detect linebreak in UITextView

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

问题描述

有没有一种方法可以检测用户发生的换行符或textview自动更改换行符的情况.我将根据行数更改textview的高度.

Is there a way to detect line breaks occurred by the user or when the textview automatically changes line. I am going to change the height of the textview depending on the number of lines.

任何帮助表示赞赏.

推荐答案

您可以使用此答案中提出的方法查找换行符@"\ n"的出现. 您可以使用textViewDidChange:协议方法(

You can use the method proposed in this answer to find the occurrences of @"\n", the newline character. You can see if the string change using the textViewDidChange: protocol method (apple doc here).

如果您想直接获得高度,请查看此答案.我认为这会有所帮助.

If you want the heigh, directly, look at this answer. I think it can help.

这篇关于在UITextView中检测换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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