UIPageViewController跳跃切换的问题
使用的是XHScrollMenu和UIPageViewController来构建5个页面:
ViewController1, ViewController2, ViewController3, ViewController4, ViewController5。
XHScrollMenu和UIPageViewController左右滑动均可以控制页面的切换。
一般情况下是正确的。
但如果点击了menu,切换ViewController1,然后再点击menu直接切换至ViewController5。
从ViewController5向右滑动往回切换的时候发现始终会直接切换至ViewController1,而不是ViewController4。
我用一个int变量来标识当前的页面,以此作为跳转的依据,但不起作用,原因是UIPageViewController调用Delegate的时候自动使用了ViewController1。
这可能是UIPageViewController的Bug,或者是一种缓存机制。
它的特点如下:
.
self . pageViewController = [[ UIPageViewController alloc ] initWithTransitionStyle : UIPageViewControllerTransitionStyleScroll navigationOrientation :UIPageViewControllerNavigationOrientationHorizontal options : nil ];
.使用menu来控制切换的代码如下
- ( void)scrollMenuDidSelected:( XHScrollMenu *)scrollMenu menuIndex:( NSUInteger)selectIndex {
[_ pageViewController setViewControllers :[ NSArray arrayWithObject :[self viewControllerAtIndex :selectIndex]] direction :UIPageViewControllerNavigationDirectionForward animated : YES completion : NULL ]
}
最后修改:
- ( void)scrollMenuDidSelected:( XHScrollMenu *)scrollMenu menuIndex:( NSUInteger)selectIndex {
if (selectIndex > _pageIndex) { //前翻或者后翻的条件判断
__block XX ViewController *blocksafeSelf = self;
[ self . pageViewController setViewControllers :[ NSArray arrayWithObject :[ self viewControllerAtIndex :selectIndex]] direction :UIPageViewControllerNavigationDirectionForward animated : YES completion :^( BOOL finished) {
if (finished) {
dispatch_async( dispatch_get_main_queue(), ^{
[blocksafeSelf. pageViewController setViewControllers :[ NSArray arrayWithObject :[blocksafeSelf viewControllerAtIndex :selectIndex]] direction :UIPageViewControllerNavigationDirectionForward animated : NO completion : NULL ]; // bug fix for uipageview controller
});
}
}];
} else {
__block RCOnlineViewController *blocksafeSelf = self;
[ self . pageViewController setViewControllers :[ NSArray arrayWithObject :[ self viewControllerAtIndex :selectIndex]] direction :UIPageViewControllerNavigationDirectionReverse animated : YES completion :^( BOOL finished){
if (finished) {
dispatch_async( dispatch_get_main_queue(), ^{
[blocksafeSelf. pageViewController setViewControllers :[ NSArray arrayWithObject :[blocksafeSelf viewControllerAtIndex :selectIndex]] direction :UIPageViewControllerNavigationDirectionReverse animated : NO completion : NULL ]; // bug fix for uipageview controller
});
}
}];
}
}
UIPageViewController跳跃切换的问题的更多相关文章
- [Cocos2d-x For WP8]Transition 场景切换
在游戏中通常会打完了一关之后就会从当前的场景转换到另外一关的场景了,在Cocos2d-x中是由CCScene类表示一个场景.那么场景(CCScene)是为游戏中的精灵(CCSprite)提供了舞台,场 ...
- Learning Cocos2d-x for WP8(6)——场景切换和场景过渡效果
原文:Learning Cocos2d-x for WP8(6)--场景切换和场景过渡效果 C#(wp7)兄弟篇 Learning Cocos2d-x for XNA(6)——场景切换和场景过渡效果 ...
- 新CCIE笔记-路由器的配置
CCIE重修笔记之路由器基本配置与最简单的路由. 路由器与交换机的基本配置命令 全局配置模式下有多种子模式 (华为可以跳跃切换模式) 思科命令行技巧 Tab键补全,也可以直接保留缩写 问号'?'类似l ...
- [特斯拉组件]ios高性能PageController
本文来自于腾讯Bugly公众号(weixinBugly),作者:sparrowchen,未经作者同意,请勿转载,原文地址: http://mp.weixin.qq.com/s/hBgvPBP12IQ1 ...
- 初学Cocos2dx
初学cocos2dx Cocos2dx 中的主要概念包括:应用.导演.场景.层.精灵.动画.动作. Cocos2dx里面的主要类 1.CCObject Object Object Object 是co ...
- iOS UIPageViewController缺陷
为什么弃用UIPageViewController?问题1:设置UIPageViewController为UIPageViewControllerTransitionStyleScroll且调用set ...
- iOS UIPageViewController
UIPageViewController是App中常用的控制器.它提供了一种分页效果来显示其childController的View.用户可以通过手势像翻书一样切换页面.切换页面时看起来是连续的,但静 ...
- iOS如何随意的穿插跳跃,push来pop去
iOS如何随意的穿插跳跃,push来pop去? 主题思想:如A.B.C.D 四个视图控制器. 想要在 A push B 后, B 在push 到 D ,然后从 D pop 到 C ,在从 C pop ...
- 一些有用的 Emacs 配置(窗口快速切换、一键透明效果、任意位置删除整行等)
本篇文章记录的是一些有用的 Emacs 配置,有些是自己原创,有些是借鉴别人(能记起来出处的我放了链接). 规定:C 代表 Ctrl,M 代表 Alt. 1.设置一次跳跃 n 行的快捷键 按 C-M- ...
随机推荐
- 【转】android camera(一):camera模组CMM介绍
关键词:android camera CMM 模组 camera参数平台信息:内核:linux系统:android 平台:S5PV310(samsung exynos 4210) 作者:xubin ...
- UIScollView Touch事件
customScrollView.h #import <UIKit/UIKit.h> @interface customScrollView : UIScrollView @end cus ...
- DICOM:C-GET与C-MOVE对照剖析
背景: 之前专栏中介绍最多的两款PACS各自是基于dcmtk的dcmqrscp以及Orthanc.和基于fo-dicom的DicomService(自己开发的).该类应用场景都是针对于局域网,因此在使 ...
- 电子设计省赛--DMA与ADC
//2014年4月17日 //2014年6月20日入"未完毕" //2014年6月21日 DMA可实现无需cpu控制中断的传输数据保存. 特别是ADC转换多个通道时要用到. 关键是 ...
- 新生赛(2) problem 2 丁磊养猪
Problem B Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Sub ...
- webconfig 初认识
本文摘自网络大神们,还有待补充. -------------------------------------------------------------------- .net 提供的是针对当前机 ...
- escape和unescape给字符串编码
var before = "\xxx\xxx" var after = escape(before); var after2 = unescape(after );
- Sublime Text插件FileHeader实践
FileHeader是一个文件模板插件,可以定制各种文件模板和文件头部信息,保存时可以自动更新文件的修改时间.在多人开发中这个功能相当实用. 具体介绍我就不细说了,主要是分享一下在使用FileHead ...
- USACO OPEN 12 BOOKSELF(转)
原文出处:http://txhwind.blog.163.com/blog/static/2035241792012112285146817/(版权为原作者所有,本博文无营利目的,不构成侵权) 题目大 ...
- OpenRisc-40-or1200的MMU模块分析
引言 MMU(memory management unit),无论对于computer architecture designer还是OS designer,都是至关重要的部分,设计和使用的好坏,对性 ...