0

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?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
smecperson
  • 301
  • 1
  • 4
  • 15

1 Answers1

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