首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多个UIPageViewController

多个UIPageViewController
EN

Stack Overflow用户
提问于 2014-12-03 16:12:34
回答 1查看 141关注 0票数 0

我使用一个带有UIPageViewController (first pvc)的UINavigationController作为根控制器。在这个pvc实例中,我有多个视图,我可以在其中滚动。这一切都运行得很好。

然后,我选择从这些视图之一进行推送,向下钻取到具有第二个pvc的级别。当我滚动第二个UIPageViewController并到达序列的末尾时,我会自动继续滚动第一个pvc。

我的问题是如何禁用手势并在第二个pvc中滚动的那一刻锁定第一个pvc的滚动?

下面是导航控制器堆栈

代码语言:javascript
复制
/////--UINavigationController

/////----------UIPageViewController (first instance of pvc)

/////---------------UITableViewController [ TV01 ] push here to second pvc

/////---------------UITableViewController [ TV02 ]

/////---------------UITableViewController [ TV03 ]

/////---------------------UIPageViewController (second instance of pvc)

/////---------------------------UIViewController 

/////---------------------------UIViewController

/////---------------------------UIViewController (is scrolling to TV02)
EN

回答 1

Stack Overflow用户

发布于 2014-12-08 17:31:29

我对我的问题有一个解决方案,我想在这里发布我的答案。主UIPageViewController使用一些UIScrollView对象来处理滚动(至少对于transitionStyle UIPageViewControllerTransitionStyleScroll)。在推送新的UIPageViewController之前,我已经禁用了这个UIPageViewController的滚动选项。因此,您始终有一个活动的UIPageViewController用于滑动。

您可以通过迭代控制器的子视图(pageViewController.view.subviews)来获取它。

代码语言:javascript
复制
-(void)setScrollEnabled:(BOOL)enabled forPageViewController:(UIPageViewController*)pageViewController{
    for(UIView* view in pageViewController.view.subviews){
        if([view isKindOfClass:[UIScrollView class]]){
            UIScrollView* scrollView=(UIScrollView*)view;
            [scrollView setScrollEnabled:enabled];
            return;
        }
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27266619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档