Piero
Piero

Reputation: 9273

UIScrollView change scroll position every visit of the view

i have a UIViewController with a UIView, and in the view i have a UIScrollView, i initialized the UIViewController in this way:

if (!self.detailViewController) {
    self.detailViewController = [[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] autorelease];
}

when i enter in the View, the UIScrollView it's scroll at Top, if i return back in the MasterView, and then i go again in the DetailView, the view is scrolled at certain position, if i go back, and then i return in the view again, the view is scrolled at another position in the bottom, and again again again, every time i enter, the UIScrollView scroll a little in the bottom every time, so my question is why?...how i can set to top every time i enter in the view?

i have tried this:

[self.myScrollView scrollRectToVisible:CGRectMake(0, 0, self.myScrollView.frame.size.width, self.myScrollView.frame.size.height) animated:NO];

in the viewWillAppear method but don't change anything, so i have put it in the viewDidAppear method, and i see it return up at the top when i enter, so my question is how i can set the uiscrollview to display always at the top?

Upvotes: 1

Views: 1352

Answers (1)

mprivat
mprivat

Reputation: 21902

Try [self.myScrollView scrollRectToVisible:CGRectMake(0, 0, 10, 10) animated:NO];

Upvotes: 0

Related Questions