Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView autoscroll to last line

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.

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.

Thanks

like image 248
Mihai Damian Avatar asked Dec 07 '25 10:12

Mihai Damian


1 Answers

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.
}
like image 164
Jane Sales Avatar answered Dec 10 '25 01:12

Jane Sales



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!