diff --git a/SMPageControl.m b/SMPageControl.m index e3fe668..15717a6 100755 --- a/SMPageControl.m +++ b/SMPageControl.m @@ -342,7 +342,14 @@ - (void)sizeToFit - (void)updatePageNumberForScrollView:(UIScrollView *)scrollView { - NSInteger page = (int)floorf(scrollView.contentOffset.x / scrollView.bounds.size.width); + // Use the trailing edge on reverse and leading edge on forward + NSInteger page; + if (self.currentPage * scrollView.bounds.size.width > scrollView.contentOffset.x) { + page = (int)ceilf(scrollView.contentOffset.x / scrollView.bounds.size.width); + } else { + page = (int)floorf(scrollView.contentOffset.x / scrollView.bounds.size.width); + } + self.currentPage = page; }