Disable/enable scrolling in UIPageViewController
Try looping through the gestureRecognizers
of the UIPageViewController
and disable/enable them:
for (UIGestureRecognizer *recognizer in pageViewController.gestureRecognizers) {
recognizer.enabled = NO;
}
Note: as found in this SO post, this method will only work for UIPageViewControllerTransitionStylePageCurl
. You may want to try this solution (although it seems to be a bit hacky).
for recognizer in pageViewController.gestureRecognizers {
recognizer.isEnabled = false
}
Or you can cast in your PagingVC To disable paging:
self.delegate = nil;
self.dataSource = nil;
And for enable it again:
self.delegate = self;
self.dataSource = self;
Setting the UIPageViewController dataSource
property to nil
prevents scrolling, because the page view controller does not have a way to determine the "next" view controller to transition to.
self.dataSource = nil // scrolling disabled
self.dataSource = self // scrolling enabled
I did the following thing (I have a controller that holds UIPageViewController).
self.pageController.view.userInteractionEnabled = NO;
And when you want to enable swipe or scroll, just enable user interaction.