To know on which page you are, and so, increment or decrement a counter, you can know the page number using this:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
CGFloat ratio = scrollView.contentOffset.x/scrollView.frame.size.width;
self.pageControl.currentPage = (int)floor(ratio); // page number
}
To detect the scrolling direction, you can use this:
//somewhere in the header
@property (nonatomic, assign) CGFloat lastContentOffset;
@property (nonatomic, assign) int counter;
//
- (void)scrollViewDidScroll:(UIScrollView *)sender
{
ScrollDirection scrollDirection;
if (self.lastContentOffset > scrollView.contentOffset.x)
scrollDirection = ScrollDirectionRight;
else if (self.lastContentOffset < scrollView.contentOffset.x)
scrollDirection = ScrollDirectionLeft;
self.lastContentOffset = scrollView.contentOffset.x;
// do whatever you need to with scrollDirection here.
self.counter = (scrollDirection == ScrollDirectionRight) ? self.counter++ : self.counter--;
}
Seen on this post