iOS4: Can't Programmatically Scroll to Bottom of UITextView

OscarTheGrouch picture OscarTheGrouch · Jul 3, 2010 · Viewed 10.1k times · Source

Before I was using this method....

//TextView is a UITextView 

[TextView scrollRangeToVisible:NSMakeRange([TextView length], 0)];

...which would programmatically scroll to the end of the UITextView but it doesn't seem to be working in iOS 4.0. Is there a way to programmatically scroll to the end of a UITextView without changing editablility or inserting a point (where the user can tap on the UITextView and have a keyboard show up)?

Also, do I need to assign the file owner as the delegate? Does it make a difference?

Answer

ashphy picture ashphy · Feb 24, 2011

UITextView doesn't have length property. Following code works good for my environment.

[TextView scrollRangeToVisible:NSMakeRange([TextView.text length], 0)];