UIScrollView 在 UIPageViewController 中滚动了多少? [英] How much a UIScrollView has been scrolled inside a UIPageViewController?

查看:19
本文介绍了UIScrollView 在 UIPageViewController 中滚动了多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚在我的 UIPageViewController 中滚动了多少滚动视图.我在 viewLoad 中有以下代码从 UIPageViewController 访问 UIScrollView.

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;
    }
}

因此,一旦我有了 UIScrollView,称为 thisControl,我想通过执行以下操作来打印滚动了多少:

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?

推荐答案

设置委托给那个控制器(myScroll.delegate = self;) 然后添加这个方法:

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
}

这篇关于UIScrollView 在 UIPageViewController 中滚动了多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆