0

I have a page control with 2 pages. I allow zooming on both pages also. when I am zoomed in on the 2nd page, and I scroll around, the currentPage of the page control goes back to page 1 even though i am still on the 2nd page.

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    CGFloat pageWidth = scrollView.frame.size.width;
    int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    _pageControl.currentPage = page;
}
Thilina Chamath Hewagama
  • 9,039
  • 3
  • 32
  • 45
Adam Johns
  • 35,397
  • 25
  • 123
  • 176

1 Answers1

0

I changed how I calculated my page to

int page = scrollView.contentOffset.x / scrollView.frame.size.width;

as shown here: Getting the current page

Community
  • 1
  • 1
Adam Johns
  • 35,397
  • 25
  • 123
  • 176
  • Hi, I am trying to accomplish the exact thing, I cannot get the scrollview to work, I posted a question here. http://stackoverflow.com/questions/18476944/uiscrollview-sliding-zooming Do you have a sample project I can look at? Thanks. – Huang Aug 27 '13 at 23:22