问题
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?
回答1:
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
}
来源:https://stackoverflow.com/questions/22768550/how-much-a-uiscrollview-has-been-scrolled-inside-a-uipageviewcontroller