Question

I'm trying to figure out how much of the scroll view inside my UIPageViewController has been scrolled. I have the following code in the viewLoad that access the UIScrollView from UIPageViewController.

for (UIView *view in self.pageViewController.view.subviews) 
{
    if ([view isKindOfClass:[UIScrollView class]]) 
    {
        thisControl = (UIScrollView *)view;
    }
}

So once I have the UIScrollView, called thisControl I would like to print how much has been scrolled by doing something like this:

NSLog (@"Scroll: %f",thisControl.contentOffset.x);

The problem, is that I don't really know where to put this line, or how print continuously how much has been scrolled. Any idea?

Was it helpful?

Solution

Set the delegate to that controller(myScroll.delegate = self;) and then add this method:

- (void) scrollViewDidScroll: (UIScrollView *) scrollView
{
  CGFloat y = scrollView.contentOffset.y;
  NSLog(@"%f",y);
  // some stuff
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top