I have an UIView
and I add a editable UITextView
to it,
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 219, 47)];
[self addSubview:textView];
textView.font = [UIFont systemFontOfSize:14];
When I type it doesn't go down automatic. Anybody got an idea?
Just figured out that you must use a length > 0. Ie
NSRange range = NSMakeRange(textView.text.length - 1, 1);
[textView scrollRangeToVisible:range];
Worked for me anyway.
To scroll to the end of the buffer I tried
[textView scrollRangeToVisible:NSMakeRange([textView.text length]-1, 1)];
But nothing happened. Instead this works
textView.selectedRange = NSMakeRange(textView.text.length - 1, 0);
I think you'll have to do
[textView scrollRangeToVisible:[textView selectedRange]];
in textDidChange
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With