本文介绍了UIPageViewController使用Scroll过渡样式导航到错误的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的UIPageViewController在iOS 5中运行良好。但是当iOS 6出现时,我想使用新的滚动转换样式(UIPageViewControllerTransitionStyleScroll)而不是页面卷曲样式。这导致我的UIPageViewController中断。

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.

除非我调用 setViewControllers之后才能正常工作:方向:动画:完成:。之后,下次用户手动滚动一页时,我们会得到错误的页面。这里有什么问题?

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?

推荐答案

这个bug的解决方法是在完成设置相同的viewcontroller但没有动画时创建一个块

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

这篇关于UIPageViewController使用Scroll过渡样式导航到错误的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 06:24