I cannot find the correct solution for autoscroll UITextView using Swift .
UITextView
For my application, I get persistent data from BT, and I update it on a UITextView . However, when the UITextView reaches the last updated row, I will have to manually scroll.
What I'm trying to achieve is to keep the last added row in a UITextView visible. (using quick)
This will scroll to the bottom of the UITextView with animation:
let range = NSMakeRange(textView.text.characters.count - 1, 0) textView.scrollRangeToVisible(range)
You can 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.