简体   繁体   English

禁用和重新启用Page View Controller手势识别器?

[英]Disable and Reenable Page View Controller gesture recogniser?

I have a page view controller that the user can swipe between views. 我有一个页面视图控制器,用户可以在视图之间滑动。

I want to stop the user from being able to swipe between the views ridiculously fast by temporarily disabling then reenabling the page view controller gesture recogniser. 我想通过暂时禁用然后重新启用页面视图控制器手势识别器,来阻止用户快速在视图之间疯狂地滑动。

How can I programmatically disable and reenable the page view controllers gestures recogniser? 如何以编程方式禁用和重新启用页面视图控制器手势识别器?

Here is an example of something I am ideally trying to do. 这是我理想地尝试做的事的一个例子。

- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed
{

enableSwiping = NO;

} 

I don't think UIPageViewController has an API to do that sort of thing but by returning only a subset of views from the data source method you can achieve the required behaviour. 我认为UIPageViewController没有API可以执行此类操作,但是通过仅从数据源方法返回视图的子集,您可以实现所需的行为。

Take a look at this question on SO which talks about disabling scrolling for page View controller Disable Page scrolling in UIPageViewController 看看SO上的这个问题,它讨论了禁用页面View Controller的滚动禁用UIPageViewController中的页面滚动

So for your requirement you should only return say the first two pages until the user scrolls till second page. 因此,根据您的要求,您只应返回说前两页,直到用户滚动到第二页为止。 Then you can return the next two pages.... 然后,您可以返回下两页...。

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

相关问题 View中的手势识别器和使用View Controller作为Target,我的设计错了吗? - Gesture recogniser in View and use View Controller as Target, is my design wrong? 向UIWindow上添加的视图添加手势识别器 - Adding a gesture recogniser to a view which added on UIWindow iOS:用于平滑滚动和轻弹视图的手势识别器 - iOS: Gesture recogniser for smooth scrolling and flicking a View 如何在UITextField和UISearchBar中禁用长按手势识别器? - How to disable Long press gesture recogniser in UITextField and UISearchBar? 将按钮视图添加到标签视图作为子视图时,手势识别器无法正常工作 - Gesture recogniser not working when added button view to the Label view as subview 在不使用手势识别器的情况下,通过轻按外部来缩小视图 - Shrink a view based on tapping outside, without using gesture recogniser 我可以将手势识别器的代码放在视图的子类中吗? - Can I put the code for a gesture recogniser in the subclass of a view? 不同类别的手势识别器? - Gesture recogniser in different class? 滑动手势识别器未触发? - Swipe Gesture Recogniser not triggering? 带有手势识别器的UICollectionView - UICollectionView with gesture recogniser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM