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?
UITextView doesn't have length property. Following code works good for my environment.
[TextView scrollRangeToVisible:NSMakeRange([TextView.text length], 0)];
The answer didn't work for me, but following what you would use for a TableView works perfect. Just make sure your UITextView is named textView.
if (textView.contentSize.height > textView.frame.size.height)
{
CGPoint offset = CGPointMake(0, textView.contentSize.height - textView.frame.size.height);
[self.textView setContentOffset:offset animated:YES];
}
In IOS8, a call to ensureLayoutForTextContainer seems to make this solution work.. Took me nearly an hour to track this down.
logObject.layoutManager.ensureLayoutForTextContainer(logObject.textContainer)
logObject.setContentOffset(CGPointMake(0.0, logObject.contentSize.height), animated:false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With