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- ...
随机推荐
- GridBagLayout练习
摘自http://blog.csdn.net/qq_18989901/article/details/52403737 GridBagLayout的用法 GridBagLayout是面板设计中最复杂 ...
- Eclipse SVN插件的帐号、password改动
问题描写叙述: Eclipse的SVN插件Subclipse做得非常好,在svn操作方面提供了非常强大丰富的功能.但到眼下为止,该插件对svn用户的概念极为淡薄,不但不能方便地切换用户,并且一旦用户的 ...
- 阿里云RDS导入服务器数据库 XtraBackup
如果是centos系统,默认会开启selinux 一定需关闭selinux 解决方法:关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=dis ...
- Java - 反射机制 2
package spring.classloader; import java.lang.reflect.Constructor; import java.lang.reflect.Field; im ...
- 使用bulkCopy心得
最近一直在到excel导入,无意中发现Bulk Insert 批量导入,于是研究了一下,在测试的时候一直有问题,然后找度娘帮忙,说新增DataTable数据结构的时候,每个列要与数据库设计时字段对应, ...
- Reverse Words in a String (JAVA)
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...
- visual studio 2015 修改类class 文件模板
第一步:找到模板文件 路径:C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\C ...
- .NET进阶系列之一:C#正则表达式整理备忘
有一段时间,正则表达式学习很火热很潮流,当时在CSDN一天就能看到 好几个正则表达式的帖子,那段时间借助论坛以及Wrox Press出版的<C#字符串和正则表达式参考手册>学习了一些基础的 ...
- Windows下Vundle安装
鼠标手老是发作,没办法.想学习vim尽量减少编码时使用鼠标的频率.安装好gVim开始安装Vundle插件,总结下安装过程和各种遇到的坑: github上VundleVim倒是有说明 Windows S ...
- 设计模式--委托模式C++实现
原文章地址:http://www.cnblogs.com/zplutor/archive/2011/09/17/2179756.html [委托模式 C++实现] 我对.Net的委托模型印象很深刻,使 ...