UITextView 在插入每一行后继续滚动,因此这些行是不可见的(iPhone 操作系统) [英] UITextView keep scrolling after every new line is inserted, so the lines are invisible (iPhone OS)

查看:50
本文介绍了UITextView 在插入每一行后继续滚动,因此这些行是不可见的(iPhone 操作系统)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 UITextView 和一个有问题的情况.我在 UITextView 中写了一行文本,然后按回车换行.发生的情况是,我输入的行向上移动,所以我看不到它,我可以继续写.这对我来说是不好的行为,因为我需要保持线条,并且只有在到达 UITextView 底部时才会向上移动.

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.

  • 我读过其他类似的帖子,但没有帮助.

有人熟悉这个东西吗?

推荐答案

我很幸运地使用了这个解决方案:如何阻止UITextView在输入时向上滚动

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

然而,我还发现根据我的 UITextView 的大小,让它正确滚动所需的 insets 变化并且子类化并不总是必要的.例如,对于高度为 40(对于 UITextView 来说非常小)的文本视图,我执行了以下操作:

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);

这篇关于UITextView 在插入每一行后继续滚动,因此这些行是不可见的(iPhone 操作系统)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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