I have a scroll view with paging enabled, and I want it to go to the next page when a button is pressed. Is this possible? Is there a method to do so?
Asked
Active
Viewed 932 times
0
-
1You need to set the content offset, there is no **go to next page method** in UIScrollView `- (void)setContentOffset:animated:` – Burhanuddin Sunelwala Apr 15 '15 at 05:00
-
1possible duplicate of [Change page on UIScrollView](http://stackoverflow.com/questions/1926810/change-page-on-uiscrollview) – Burhanuddin Sunelwala Apr 15 '15 at 05:00
1 Answers
1
You can scroll to some point in a scroll view with
[scrollView setContentOffset:CGPointMake(x, y) animated:YES];
To do slideshows with UIScrollView, you arrange all images in the scroll view, set up a repeated timer, then -setContentOffset:animated: when the timer fires.
But a more efficient approach is to use 2 image views and swap them using transitions or simply switching places when the timer fires. See for details.
OR
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * pageNumberYouWantToGoTo;
frame.origin.y = 0;
[scrollView scrollRectToVisible:frame animated:YES];

Community
- 1
- 1

Rahul Mayani
- 3,761
- 4
- 25
- 40