auto scroll for UITextView using swift (IOS app)
You could also set contentOffset:
let point = CGPoint(x: 0.0, y: (textView.contentSize.height - textView.bounds.height))
textView.setContentOffset(point, animated: true)
It will scroll to the bottom.
Swift 5 update for @SwiftArchitect answer:
let range = NSRange(location: textView.text.count - 1, length: 0)
textView.scrollRangeToVisible(range)
This will scroll to the bottom of a UITextView
, with an animation:
let range = NSMakeRange(textView.text.characters.count - 1, 0)
textView.scrollRangeToVisible(range)