Detect linebreak in UITextView

北战南征 提交于 2019-12-06 12:54:35
Francesco

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.

You can get the number of rows which is actually what i wanted to do.

numLines = textView.contentSize.height/textView.font.leading;

put this code into textViewDidChange:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!