ios6uipageviewcontroller

UIPageViewController navigates to wrong page with Scroll transition style


My UIPageViewController was working fine in iOS 5. But when iOS 6 came along, I wanted to use the new scroll transition style (UIPageViewControllerTransitionStyleScroll) instead of the page curl style. This caused my UIPageViewController to break.

It works fine except right after I've called setViewControllers:direction:animated:completion:. After that, the next time the user scrolls manually by one page, we get the wrong page. What's wrong here?


Solution

  • 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
                    });
                }
            }];