我使用一个带有UIPageViewController (first pvc)的UINavigationController作为根控制器。在这个pvc实例中,我有多个视图,我可以在其中滚动。这一切都运行得很好。
然后,我选择从这些视图之一进行推送,向下钻取到具有第二个pvc的级别。当我滚动第二个UIPageViewController并到达序列的末尾时,我会自动继续滚动第一个pvc。
我的问题是如何禁用手势并在第二个pvc中滚动的那一刻锁定第一个pvc的滚动?
下面是导航控制器堆栈
/////--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)发布于 2014-12-08 17:31:29
我对我的问题有一个解决方案,我想在这里发布我的答案。主UIPageViewController使用一些UIScrollView对象来处理滚动(至少对于transitionStyle UIPageViewControllerTransitionStyleScroll)。在推送新的UIPageViewController之前,我已经禁用了这个UIPageViewController的滚动选项。因此,您始终有一个活动的UIPageViewController用于滑动。
您可以通过迭代控制器的子视图(pageViewController.view.subviews)来获取它。
-(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;
}
}
}https://stackoverflow.com/questions/27266619
复制相似问题