Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change page on UIScrollView

I have a UIScrollView with 10 pages. I am able to flick between them. I also want to have 2 buttons (a back button and a next button) which when touched will go to the previous or next page. I can't seem to figure out a way to do this though. A lot of my code comes from Apple's page control sample code. Can anybody help?

Thanks

like image 509
john Avatar asked Dec 18 '09 07:12

john


People also ask

What is Ui Scroll view?

UIScrollView is the superclass of several UIKit classes, including UITableView and UITextView . A scroll view is a view with an origin that's adjustable over the content view. It clips the content to its frame, which generally (but not necessarily) coincides with that of the app's main window.


1 Answers

You just tell the buttons to scroll to the page's location:

CGRect frame = scrollView.frame; frame.origin.x = frame.size.width * pageNumberYouWantToGoTo; frame.origin.y = 0; [scrollView scrollRectToVisible:frame animated:YES]; 
like image 169
mjdth Avatar answered Oct 02 '22 15:10

mjdth