tags:

views:

444

answers:

2

I have a large amount of text in a UITextView. I want to let the user press a button and save the line that is displayed at the top of the view. Then when the same button is pressed it jumps to that exact line when the app is opened at a later time. Just like a physical bookmark.

How can I determine where the text is, or scrolling is? How can I auto scroll to that position later?

+1  A: 

UITextView is a subclass of UIScrollView, so you can use the UIScrollView messages contentOffset and setContentOffset:animated: to get and set the scrolling offset respectively.

Adam Rosenfield
A: 

I can't believe how easy that was...

Thank you

//grab current spot of scrollbar, usage: p.x & p.y as integers

CGPoint p = myText.contentOffset;

//

//

//scroll myText to a particular point

[myText setContentOffset:CGPointMake(0, 0) animated:NO];