Auto scroll for UITextView using fast (iOS app)

I cannot find the correct solution for autoscroll UITextView using Swift .

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)

+6
source share
2 answers

This will scroll to the bottom of the UITextView with animation:

 let range = NSMakeRange(textView.text.characters.count - 1, 0) textView.scrollRangeToVisible(range) 
+10
source

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.

0
source

All Articles