How much a UIScrollView has been scrolled inside a UIPageViewController?

醉酒当歌 提交于 2019-12-11 11:20:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!