Refresh UIPageViewController – reorder pages and add new pages

I found a workaround to force UIPageViewController to forget about cached view controllers of neighboring pages that are currently not displayed: pageViewController.dataSource = nil; pageViewController.dataSource = self; I do this everytime I change the set of pages. Of course this doesn’t affect the currently displayed page. With this workaround I avoid the caching bug and … Read more

Disable UIPageViewController bounce

Disable UIPageViewController’s bounce Add the <UIScrollViewDelegate> delegate to your UIPageViewController’s header Set the UIPageViewController’s underlying UIScrollView’s delegates to their parent in viewDidLoad: for (UIView *view in self.view.subviews) { if ([view isKindOfClass:[UIScrollView class]]) { ((UIScrollView *)view).delegate = self; break; } } The implementation for scrollViewDidScroll is to reset the contentOffset to the origin (NOT (0,0), but … Read more

UIPageViewController and storyboard

2020. Swift updated. 2017 answer… Nowadays it is dead easy to do this simply using Storyboard. These sort of “swiping full-screen tutorials” were popular as app “intros” for awhile, so I called the class below IntroPages. Step 1, make a container view that is a UIPageViewController. If new to iOS, here is a container view … Read more

UIPageViewController, how do I correctly jump to a specific page without messing up the order specified by the data source?

Programming iOS6, by Matt Neuburg documents this exact problem, and I actually found that his solution feels a little better than the currently accepted answer. That solution, which works great, has a negative side effect of animating to the image before/after, and then jarringly replacing that page with the desired page. I felt like that … Read more

UIPageViewController navigates to wrong page with Scroll transition style

My workaround of this bug was to create a block when finished that was setting the same viewcontroller but without animation __weak YourSelfClass *blocksafeSelf = self; [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished){ if(finished) { dispatch_async(dispatch_get_main_queue(), ^{ [blocksafeSelf.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];// bug fix for uipageview controller }); } }];

How do I Disable the swipe gesture of UIPageViewController?

The documented way to prevent the UIPageViewController from scrolling is to not assign the dataSource property. If you assign the data source it will move into ‘gesture-based’ navigation mode which is what you’re trying to prevent. Without a data source you manually provide view controllers when you want to with setViewControllers:direction:animated:completion method and it will … Read more

Is it possible to Turn page programmatically in UIPageViewController?

Yes it is possible with the method: – (void)setViewControllers:(NSArray *)viewControllers direction:(UIPageViewControllerNavigationDirection)direction animated:(BOOL)animated completion:(void (^)(BOOL finished))completion;` That is the same method used for setting up the first view controller on the page. Similar, you can use it to go to other pages. Wonder why viewControllers is an array, and not a single view controller? That’s because … Read more

UIPageViewController: return the current visible view

You should manually keep track of the current page. The delegate method pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted: will tell you when to update that variable. The last argument of the method transitionCompleted: can tell you whether a user completed a page turn transition or not. Then, you can get the currently presented View Controller by doing self.viewControllers?.first

tech