Alex Wulff Alex Wulff - 4 months ago 94
iOS Question

UITextView Starts at Bottom or middle of text

I'll get right to it. I have a UItextView placed in my view that when needs to scroll to see all the text (when a lot of text is present in the textView) the textView starts in the middle of the text sometimes and the bottom of the text other times. I do not have enough reputation to post photos directly, but here's a link to one at tinypic: http://i61.tinypic.com/2q179cm.png.

Editing is not enabled on the textView. I need a way to force the textView to start at the top, every time. I saw some questions somewhat like this where other people used a content offset, but I do not really know how that works or if it would even be applicable here. Thanks for your help.

Answer

That did the trick for me!

Objective C:

[self.textView scrollRangeToVisible:NSMakeRange(0, 0)];

Swift:

self.textView.scrollRangeToVisible(NSMakeRange(0, 0))
Comments