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- ...
随机推荐
- php编程提高执行效率技巧
PHP开发提高效率技巧 0.用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作 ...
- 【转】android 电容屏(一):电容屏基本原理篇
关键词:android 电容屏 tp ITO 平台信息:内核:linux2.6/linux3.0系统:android/android4.0 平台:S5PV310(samsung exynos 42 ...
- 【转】linux环境变量设置
1. 显示环境变量HOME $ echo $HOME /home/terry 2. 设置一个新的环境变量WELCOME $ export WELCOME="Hello!" $ ec ...
- N种方法妙讲LIS算法
LIS算法经典汇总 假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7,可以看出来它的LIS长度为5.下面一步一步试着找出它.我们定义一个序列B,然后令 i = 1 to 9 逐个 ...
- 理解Servlet及其对象
一.ServeltConfig对象 在Servlet的配置文件中,可以使用一个或多个<init-param>标签为Servlet配置一些初始化参数.而不当Servlet配置了初始化参数后, ...
- ASCII码表完整版
ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 0 NUT 32 (space) 64 @ 96 . 1 SOH 33 ! 65 A 97 a ...
- cacti出现snmp error
一.在被监控机器中确认snmp是否启动 service snmpd status [root@test2 ~]# service snmpd status snmpd (pid 1247) 正在运行 ...
- 冒泡排序 选择排序 插入排序希尔排序 java
双向冒泡 package com.huang; public class _014_bubb_sort { int[] b={1,2}; static int a[]={12,4,35,65,43,6 ...
- pl sql练习(4)
1.ROW_NUMBER 返回连续的排位,不论值是否相等 select deptno,ename,sal, row_number () over (partition by deptno order ...
- OC准备知识
#import 与 #include区别 include完成头文件的导入,可能会导致头文件的相互引用和函数或变量的重复定义 为了解决这个问题 我们必须这样做 #ifndef Student_h #de ...