简体   繁体   中英

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.

Take a look at this question on SO which talks about disabling scrolling for page View controller Disable Page scrolling in 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....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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