I have a horizontal scrollView . 0 is the start screen. I want to set restrictions for buttons. next should scroll to the right from 0 to 5. back should scroll to the left from 5 to 0 (not -1). How to do it?
-(IBAction)next:(id)sender { self.currentPage++; CGFloat pageWidth = scroll.frame.size.width; [scroll setContentOffset:CGPointMake(pageWidth*self.currentPage, 0) animated:YES]; } -(IBAction)back:(id)sender { self.currentPage--; CGFloat pageWidth = scroll.frame.size.width; [scroll setContentOffset:CGPointMake(pageWidth*self.currentPage, 0) animated:YES]; }