Launching horizontal UIScrollView on random page

I have a horizontal UIScrollView with a bunch of different pages on it. I would like to programmatically show a specific page for a custom selection. At the moment, I can't figure out how to start showing it in the middle of the page.

Does anyone have any experience? Any help would be greatly appreciated.

Thank.

Edit: I think I can do this by setting the contentOffset.x of the UIScrollView. However, the property cannot be set. Any advice?

+1


source to share


1 answer


You want to use setContentOffset

.



CGFloat offsetX = kPageWidth * pageIndex;
[scrollView setContentOffset:CGPointMake(offsetX, 0)
                    animated:YES];

      

+5


source







All Articles