I have an UIView
and I add a editable UITextView
to it,
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 2
Swift 2.2. It works for me
func textViewDidChange(textView: UITextView) {
let bottomOffset = CGPointMake(0, textView.contentSize.height - textView.bounds.size.height)
textView.setContentOffset(bottomOffset, animated: true)
}
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.
Use contentOffset
, it will automatically scroll to down
textView.contentOffset = CGPointMake(0, textView.contentSize.height - textView.frame.size.height);