UIPageViewController翻页总是重复第二页系统bug处理

表示有点儿无语了,以为是自己写的逻辑有问题,调了一个多小时,实际有点儿没有头绪了,于是google一下,发现竟然是iOS本身的一个小Bug,苦逼的码农真心伤不起啊。

问题描述:

iOS6使用UIPageViewController通过UIPageViewControllerNavigationDirectionReverse向回跳转翻页时,总会出现下一页不对的情况,因为下一页就是跳转以前的页面所以给你的感觉就是好像上一页被缓存成下一页了。这种情况大多发生在跳转的时候,使用了动画并且切换方式是UIPageViewControllerTransitionStyleScroll.

解决办法1:

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

解决办法2(我用这种):

另外为了避免这种情况发生,也可以:
1.不使用UIPageViewControllerTransitionStyleScroll方式
2.切换时animated:NO

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容