UITextView自动滚动到最后一行 [英] UITextView autoscroll to last line

查看:371
本文介绍了UITextView自动滚动到最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在UITextView中写入更多文本而不是完全可以适合它时,文本将向上滚动,光标通常会将自己一行或两行放在视图底线之上。这是有点令人沮丧,因为我希望我的应用程序充分利用文本视图的整个高度。

When writing in a UITextView more text than can fit entirely inside it, the text will scroll up and the cursor will often place itself one or two lines above the view's bottom line. This is a bit frustrating as I want my application to make good use of the entire height of the text view.

基本上我想要的是配置UITextView写

Basically what I want is to configure the UITextView to write up to it's lowest part and not use it just for scrolling.

我已经看到了一些类似的问题这里此处此处

I've seen some similar questions here, here and here. However I've not seen a proper solution yet.

感谢

推荐答案

p>我有一个稍微不同的实现(我想禁用滚动),但我也不得不停止光标跳出我的UITextView。为此,我在我的UITextView子类中实现了一个null scrollRectToVisible。像这样:

I've a slightly different implementation (I want to disable scrolling), but I also had to stop the cursor jumping out of my UITextView. To do this, I implemented a null scrollRectToVisible in my UITextView subclass. Like this:

- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
{
// do nothing. This fixes the cursor jumping above the field defect.
}

这篇关于UITextView自动滚动到最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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