简体   繁体   English

在UIPageViewController中滚动了多少UIScrollView?

[英]How much a UIScrollView has been scrolled inside a UIPageViewController?

I'm trying to figure out how much of the scroll view inside my UIPageViewController has been scrolled. 我正在试图弄清楚我的UIPageViewController滚动视图的滚动量。 I have the following code in the viewLoad that access the UIScrollView from UIPageViewController . 我在viewLoad中有以下代码,它们从UIPageViewController访问UIScrollView

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: 所以,一旦我有了名为thisControl的UIScrollView,我想通过执行以下操作来打印已滚动的内容:

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? 任何想法?

Set the delegate to that controller( myScroll.delegate = self; ) and then add this method: 将委托设置为该控制器( myScroll.delegate = self; ),然后添加此方法:

- (void) scrollViewDidScroll: (UIScrollView *) scrollView
{
  CGFloat y = scrollView.contentOffset.y;
  NSLog(@"%f",y);
  // some stuff
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM