2

I have an iOS 5.1 project in Xcode, and I have a view controller that, when you swipe left and right, changes the information on the screen VIA UITextView. I reuse the same view controller and the problem I am having is that when you scroll down and read the text and then swipe left, the scroll position doesn't reset to the top. Is there a function I can call that will reset scroll position?

ANSWER:

Found that this was what I was looking for:

[self.textView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO];

1
  • no tableviews, just a simple textView w/ scrolling enabled Commented May 21, 2012 at 13:05

1 Answer 1

3

Try this.

[self.textView setContentOffset:CGPointMake(0, 0) animated:NO];

Hope it helps !

Sign up to request clarification or add additional context in comments.

7 Comments

should I place this is viewWillAppear? or somewhere else?
should work in view will appear--but it might be easier to create a new instance of your view controller for each screen, no?
(if you get low on memory any non visible view controllers should have their views automatically unloaded--you can reload them again)
also, if this is sort of multi-page scenario where there can be an unlimited number of view controllers, you could have just 2: create a new one for the page you are navigating to, and after navigation is complete, destroy the view controller that was just removed
this didn't work, I'm still getting the same position after each swipe
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.