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- ...
随机推荐
- 力挺8天入门wpf【转载】
8天入门wpf—— 第八天 最后的补充 摘要: 从这一篇往前看,其实wpf中还有很多东西没有讲到,不过我的原则还是将比较常用的知识点过一遍,如果大家熟悉了这些知识,基本功也就打的差不多了,后续可以等待 ...
- spring MVC做form提交Neither BindingResult nor plain target object for bean name 'command' available
这两天在做spring3.0 MVC+hibernate3.2的练习中,做简单的form提交, 一直报java.lang.IllegalStateException: Neither BindingR ...
- 【SQL】大杂烩
--------------------------------- 索引 --------------------------------- 语法: CREATE [索引类型] INDEX 索引名称 ...
- 如何安装chrome扩展,以json-handle
读取本地json文件 chrome插件安装 方式一,在线安装 直接插到json-handle地址,添加即可 https://chrome.google.com/webstore/detail/json ...
- Godaddy主机从购买到开通的详细图文教程(2013年)
http://bbs.zhujiusa.com/thread-10-1-1.html Godaddy主机从购买到开通的详细图文教程(2013年最新) Godaddy是全球域名注册商中的NO.1,同时也 ...
- 使用xib方式创建UITableViewCell,设置Label自动换行注意事项
自定义的UITableViewCell,使用xib方式创建,想要其中的UILabel换行显示:计算Label的高度,让其自动换行,总是没有效果. 我猜测原因可能在于使用了autolayout布局.只要 ...
- iOS 后台播放音乐
在info.plist文件中添加 下面是后台播放音频的完整测试代码: 引入文件<AVFoundation/AVFoundation.h> //后台播放音频设置 AVAudioSession ...
- USACO 1.4 ariprog 解题报告
这是继虫洞之后又让我为难的一个 剪枝题目,无论如何,做的再快,也只能过6个点,最后三个点也TLE.后来参考了一下标答,大概思路是这样的. 朴素算法就不多说了,枚举a,b然后判断就行,网上说这样优化到位 ...
- Windows 端口和任务 查看 相关命令
netstat -aon|findstr " //查看端口 tasklist|findstr " //根据PID找到对应的程序 taskkill /f /t /im netbox. ...
- 从汇编看c++成员函数指针(三)
前面的从汇编看c++中成员函数指针(一)和从汇编看c++成员函数指针(二)讨论的要么是单一类,要么是普通的多重继承,没有讨论虚拟继承,下面就来看一看,当引入虚拟继承之后,成员函数指针会有什么变化. 下 ...