iOS7以后的侧滑返回上一页
我们知道,iOS7以后,导航控制器默认带了侧滑返回功能,但是仅限于屏幕边缘。而且在你自定义leftBarButtonItem等之后侧滑效果就会消失。这种问题怎么解决呢?
首先,我们先来看看系统的这种手势是什么?
NSLog(@"%@",self.interactivePopGestureRecognizer);//这里的self是项目中用的navigationController
打印结果:
<UIScreenEdgePanGestureRecognizer: 0x15ecc9e0; state = Possible; delaysTouchesBegan = YES; view = <UILayoutContainerView 0x15da65a0>; target= <(action=handleNavigationTransition:, target=<_UINavigationInteractiveTransition 0x15ecc900>)>>
解决办法:自定义一个滑动手势,当手势触发时,调用系统手势的target的相应方法。经过验证,这个target就是interactivePopGestureRecognizer.delegate,方法名是:handleNavigationTransition:
上代码:
id taget = self.interactivePopGestureRecognizer.delegate;
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:taget action:@selector(handleNavigationTransition:)];
[self.view addGestureRecognizer:pan];
pan.delegate = self; //因为根控制器不需要滑动返回,所以要通过代理方法处理一下
self.interactivePopGestureRecognizer.enabled = NO; //这句不能忘啊!!!!关掉系统手势 //手势代理方法
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
if (self.childViewControllers.count == 1) {
return NO;
}
return YES;
}
参考资料
http://www.cocoachina.com/ios/20150401/11459.html
http://www.jianshu.com/p/737924684695
http://www.jianshu.com/p/c0b7a97b3b0e
iOS7以后的侧滑返回上一页的更多相关文章
- html中返回上一页的各种写法【转】
超链接返回上一页代码: <a href="#" onClick="javascript :history.back(-1);">返回上一页</ ...
- JS控制,返回上一页之后强行刷新一次
网站建设过程中,提交页面后我们经常要用到window.history.go(-1)返回上一页,因为页面的缓存功能,我们只能返回上次操作的页面,但在删除等操作中,我们希望实时看到删除项目后的页面,这就要 ...
- php实现返回上一页的功能
php实现返回上一页的功能的3种有效方法 header(location:你的上一页的路径); // 注意这个函数前不能有输出 header(location:.getenv(&qu ...
- 6种方法实现asp.net返回上一页
其实要实现返回上一页的功能,主要还是要用到JavaScript. 一: 在ASP.net的aspx里面的源代码中 <input type="button onclick="J ...
- [moka同学收藏]网页上的“返回上一页”的几种实现代码
我们在制作网页的时候,经常在网页上要用到"返回上一页"的功能.这一功能在制作网页的时候会有多种编码方法,在此,笔者将比较常用的几种编码写作方法在下面列出来,供各位技术人员参考使用. ...
- angular+ionic返回上一页并刷新
假定当前页面为editCata页面,要返回的是cataDetail页面.目前我找到两种方法实现返回上一页并刷新,如果以后有其它方法,再继续添加. 1.在editCataCtrl.js中注入$ionic ...
- js返回上一页并刷新的多种实现方法
<a href="javascript:history.go(-1)">返回上一页</a> <a href="javascript:loca ...
- JavaScript返回上一页代码区别
JavaScript返回上一页代码区别: window.history.go(-1); //返回上一页 window.history.back(); //返回上一页 //如果要强行刷新的话就是:win ...
- JS跳出框架返回上一页
链接部分 <a class="link" href="javascript:;" target="_top" onclick=&quo ...
随机推荐
- HIT Winter Day ACM入门
A. Arpa’s hard exam and Mehrdad’s naive cheat 题意:统计1378^n的末尾数字 即统计8^n的末尾数字 n=0时为1 其他情况为{8,4,2,6}中的一个 ...
- python中telnetlib模块的使用
一.Windows下开启Telnet服务 (详见:与Win7防火墙无缝结合 Telnet功能测试) 1.Windows 2000/XP/2003/Vista:默认已安装但禁止了Telnet服务 (1) ...
- Javascript:scrollWidth,clientWidth,offsetWidth的区别(转)
网页可见区域宽:document.body.clientWidth; 网页可见区域高:document.body.clientHeight; 网页可见区域高:document.body.offsetW ...
- hdu_5753_Permutation Bo(找规律)
题目连接:hdu_5753_Permutation Bo 题意: 给你一个有n个数的数列c1~cn,h1~hn为1~n的排列,求ci[hi>hi-1 and hi>hi+1]的期望和. ...
- 一个forward_list C++primer
#include<iostream> #include<forward_list> using namespace std; int main() { forward_list ...
- openwrt ramips随记
ar71xx / brcm47xx / brcm63xx / ramips是指cpu的系列,ramips是指ralink系列的
- LeetCode OJ 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using ext ...
- Cantor数表
题目:现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 第一项是1/1,第二项是是1/2,第三项是2/1,第四项是3/1,第五项是2/2,… ...
- 解决Xcode 9.2系统真机测试时出现 could not find developer disk image问题
解决Xcode在ipad/iphone 9.2 系统真机测试时出现could not find developer disk image问题 第一种方法:拷贝这个文件(http://download. ...
- App Store 升级问题
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...