UITextView keep scrolling after every new line is inserted, so the lines are invisible (iPhone OS)

本秂侑毒 提交于 2019-12-11 03:19:48

问题


I have UITextView and a situation that is problematic. I write line of text in the UITextView, and then press return for new line. What happen is, the line that i entered is moving up so i can't see it, and i am able to continue writing. This is bad behavior for me, because i need the line to stay, and only move up when i reach the bottom of the UITextView.

  • I've read other similar posts but they wasn't helpfull.

Is someone familiar with this thing?


回答1:


I had luck using this solution: How to stop UITextView from scrolling up when entering it

However, I also found depending on the size of my UITextView, the insets needed to get it to scroll correctly varied and subclassing wasn't always necessary. For instance, for a text view of height 40 (very small for a UITextView), I did the following:

textView_ = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 40)];
textView_.contentInset = UIEdgeInsetsMake(-6, -8, 0, 0);


来源:https://stackoverflow.com/questions/2733096/uitextview-keep-scrolling-after-every-new-line-is-inserted-so-the-lines-are-inv

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