I have a scrollView with 6 screens. I use it with paging mode. When I click on the nextButton go to the next screen. I click on the backButton switch to the previous screen. Everything works fine if I start scrolling from the first screen. But if I click on nextButton and start scrolling from the 5th screen, I turn to the 2nd screen. How to scroll normally from each screen?
nextButton
-(IBAction)next:(id)sender { if(self.currentPage == 6) return; self.currentPage++; CGFloat pageWidth = _scroller.frame.size.width; [_scroller setContentOffset:CGPointMake(pageWidth*self.currentPage, 0) animated:YES]; } backButton
-(IBAction)back:(id)sender { if(self.currentPage == 0) return; self.currentPage--; CGFloat pageWidth = _scroller.frame.size.width; [_scroller setContentOffset:CGPointMake(pageWidth*self.currentPage, 0) animated:YES]; }
self.currentPagedoes not change, so when you click next, it jumps to currentPage. you need to change currentPage in delegate methods - Max Mikheyenko