This is caused by a UIScrollView
bug in iOS 8. Hopefully in iOS 9 they fix it. I only assume that its a bug because resignFirstResponder
didn't have this behavior in iOS 7. Maybe its a feature.
The only way I found to prevent resignFirstResponder
and setText
from resetting the contentOffset
was the following:
Swift:
textView.layoutManager.allowsNonContiguousLayout = false
Objective C
textView.layoutManager.allowsNonContiguousLayout = NO;
Another reason I think its a bug is because the documentation says that it is set to NO by default, but when you print out the variable without setting it, its true.
More info on NSLayoutManager
can be found here