Assertion failure in UIPageViewController Assertion failure in UIPageViewController ios ios

Assertion failure in UIPageViewController


So my solution to this was adding a BOOL which keeps track of my animations state. So before setting the new ViewController, I modify this too:

if (!_transitionInProgress) {    _transitionInProgress = YES;    [self.pageController setViewControllers:@[viewController] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:^(BOOL finished) {        _transitionInProgress = !finished;    }];}

So I'll wait for my animation to finish before setting a new view controller. In my case, I have a some buttons the user can press in order to switch pages. This also prevents them from going too fast through them so the animations are always smooth and nice


This is a bug in the internal implementation of UIPageViewController in scroll mode. It happens when a transition animation occurs while the page view controller is already animating a transition. What I ended up doing was to block the UI from allowing multiple quick scrolls. I have two buttons, left and right, which make the page view controller scroll to previous or next page controller. I disable the buttons' operation while there is an animation going. The page view controller's delegate tells you all you need to know when to disable the UI's functionality and when to re-enable it, once all animations have stopped.


I am also facing this problem, but the issue is that I am unable to consistently reproduce the problem, but I can see from the crashlogs that the issue exists.

I have the pageviewcontroller which allows the user to swipe and also the view scrolls programmatically. The app crashes sometimes when you just enter the screen, but in the next attempts it works fine, so its kind of crazy. Even if I put a fix I cant be sure that it works as I am unable to reproduce it. Looks like the below code should fix it (took from Removing a view controller from UIPageViewController) atleast the screen behaves better with this code. I would really appreciate if I can get some methods to inject this crash myself, so that I can verify the fix.

- (void) setViewControllers:(NSArray*)viewControllers direction:(UIPageViewControllerNavigationDirection)direction animated:(BOOL)animated completion:(void (^)(BOOL))completion {    if (!animated) {        [super setViewControllers:viewControllers direction:direction animated:NO completion:completion];        return;    }    [super setViewControllers:viewControllers direction:direction animated:YES completion:^(BOOL finished){        if (finished) {            dispatch_async(dispatch_get_main_queue(), ^{                [super setViewControllers:viewControllers direction:direction animated:NO completion:completion];            });        } else {            if (completion != NULL) {                completion(finished);            }        }    }];}