views:

566

answers:

1

Hi, I have a scrollViewWith size width=320x10 and height=460. I add 10 images of size width=320 and height=460 in scrollview with paging enabled. Now I can scroll the from 1st image to 10th image by scrolling.

when scrollView show, it is always showed from the 1st page. I want to show initially any random page of the scrollView, such that i can scroll previous page and next page from initially. How can i do that?

+6  A: 
[scrollView setContentOffset: CGPointMake(0, y) animated: YES];

You should just need to set the y variable to the point where you would like to scroll to. For example:

[scrollView setContentOffset: CGPointMake(0, 920) animated: YES];

Should scroll to your 3rd image.

Chris Gummer
Thanks for your answer.I have exactly done this yeterday and it works fine.
faisal
Great! If an answer does work for you, please consider accepting it - http://meta.stackoverflow.com/questions/5234/accepting-answers-what-is-it-all-about
Chris Gummer
Accept Chris' answer, reward him for helping you. http://meta.stackoverflow.com/questions/5234/accepting-answers-what-is-it-all-about
JoePasq