iOS 应用全部添加滑动返回
if ([self class] == [HomeViewController class]||[self class] == [ComprehensivefinanceViewController class]||[self class] == [MyCenterViewController class]||[self class] == [CustomerManageViewController class]) {
//添加左扫和右扫手势
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tappedRightButton:)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:swipeLeft];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tappedLeftButton:)];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
[self.view addGestureRecognizer:swipeRight];
//在基类的控制器里面书写 给主控制器加轻扫手势监听
- (IBAction) tappedRightButton:(id)sender
{
NSUInteger selectedIndex = [self.tabBarController selectedIndex];
NSArray *aryViewController = self.tabBarController.viewControllers;
if (selectedIndex < aryViewController.count - 1) {
// UIView *fromView = [self.tabBarController.selectedViewController view];
//
// UIView *toView = [[self.tabBarController.viewControllers objectAtIndex:selectedIndex + 1] view];
//
// [UIView transitionFromView:fromView toView:toView duration:0.5f options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
//
// if (finished) {
[self.tabBarController setSelectedIndex:selectedIndex + 1];
// }
//
// }];
}
}
- (IBAction) tappedLeftButton:(id)sender
{
NSUInteger selectedIndex = [self.tabBarController selectedIndex];
if (selectedIndex > 0) {
// UIView *fromView = [self.tabBarController.selectedViewController view];
//
// UIView *toView = [[self.tabBarController.viewControllers objectAtIndex:selectedIndex - 1] view];
// [UIView transitionFromView:fromView toView:toView duration:0.5f options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
//
// if (finished) {
[self.tabBarController setSelectedIndex:selectedIndex - 1];
// }
//
// }];
}
}
//这样就可以 全局滑动返回
若是网页控制器实现滑动返回功能 就得在WKWebview实现
_wkWebView.allowsBackForwardNavigationGestures = YES;//打开webview页面的滑动返回
}else{
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
//就是这么简单
iOS 应用全部添加滑动返回的更多相关文章
- 再谈iOS 7的手势滑动返回功能
本文转载至 http://blog.csdn.net/jasonblog/article/details/28282147 之前随手写过一篇<使用UIScreenEdgePanGestureR ...
- iOS 7的手势滑动返回
如今使用默认模板创建的iOS App都支持手势返回功能,假设导航栏的返回button是自己定义的那么则会失效,也能够參考这里手动设置无效. if ([self.navigationController ...
- iOS开发解决页面滑动返回跟scrollView左右划冲突
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithG ...
- iOS 如何设置导航的滑动返回手势, 和系统饿一样
iOS 7 滑动返回那些事儿 2014/05/17 Wei .entry-meta .entry-header 在智能机越来越普及,屏幕越做越大的当下,滑动返回手势已经成为了一个应用的标配功能,甚至可 ...
- 类似IOS的滑动返回上一级,SwipeBackLayout-android的滑动返回类库
最近,公司在开发App的需求中增加了一个新的需求,要在android的页面中增加向右滑动的时候返回上一级页面.我刚知道这个需求的时候,感觉有点坑,可能设计那边最近接触到知乎的客户端或者是IOS的滑动可 ...
- iOS开发——实用技术OC篇&8行代码教你搞定导航控制器全屏滑动返回效果
8行代码教你搞定导航控制器全屏滑动返回效果 前言 如果自定了导航控制器的自控制器的leftBarButtonItem,可能会引发边缘滑动pop效果的失灵,是由于 self.interactivePop ...
- iOS之手势滑动返回功能-b
iOS中如果不自定义UINavigationBar,通过手势向右滑是可以实现返回的,这时左边的标题文字提示的是上一个ViewController的标题,如果需要把文字改为简约风格,例如弄过箭头返回啥的 ...
- iOS之手势滑动返回功能
iOS中如果不自定义UINavigationBar,通过手势向右滑是可以实现返回的,这时左边的标题文字提示的是上一个ViewController的标题,如果需要把文字改为简约风格,例如弄过箭头返回啥的 ...
- iOS 自定义返回按钮,保留系统滑动返回
原文链接 自定义返回按钮保留系统滑动返回手势.gif 1.简介 使用苹果手机,最喜欢的就是用它的滑动返回.作为一个开发者,我们在编写很多页面的时候,总是会因为这样那样的原因使得系统的滑动返回不可用.使 ...
随机推荐
- JPA(API)
1. Persistence EntityManagerFactory 2. EntityManager#find EntityManager#getReference EntityManager#p ...
- 停止Flink任务
1.简单粗暴 控制台中Ctrl+C 2.UI中点击"Cancel" 3.执行cancel命令,需要知道Flink的Job ID # flink cancel jobId
- Python进阶之迭代器和生成器
可迭代对象 Python中任意的对象,只要它定义了可以返回一个迭代器的__iter__方法,或者定义了可以支持下标索引的__getitem__方法,那么它就是一个可迭代对象.简单来说,可迭代对象就是能 ...
- Java I/O---获取文件目录并写入到文本
首先获取指定目录下的所有文件目录,存入List集合中,然后创建文本文件将List遍历写入文本中保存. 1.主程序类 public class Test { /** * @param args */ p ...
- C++ 头文件系列(ostream)
1. 简介 头文件ostream主要定义了一个输出流类模版basic_ostream,该模版继承自basic_ios模版. 2. basic_ostream模版 2.1 sentry类 与basic_ ...
- dropout理解:1神带9坑
Dropout是深度学习中防止过拟合的一项非常常见的技术,是hinton大神在12年提出的一篇论文里所采用的方法.有传言hinton大神的数学功底不是很好,所以他所提出的想法背后的数学原理并不是很复杂 ...
- intelij Android 搭建 java 项目
1.打开ide创建页面,点击创建项目 2.选择Android,发现下面有一段红字,解释很清楚,由于第一使用为设置Android的开发环境sdk,去设置一下就好,点击取消回到上一界面 3 配置 4.当然 ...
- QT中几个函数的使用方法
一.把字符串转换成整形demo1:QString str = "FF";bool ok;int hex = str.toInt(&ok, 16); // hex == 25 ...
- Linux的编码及编码转换
如果你需要在Linux中操作windows下的文件,那么你可能会经常遇到文件编码转换的问题.Windows中默认的文件格式是GBK(gb2312),而Linux一般都是UTF-8.下面介绍一下,在Li ...
- HBase跨地区机房的压测小程序——从开发到打包部署(图文版)
今天做了一个跨地区机房的压测小程序,主要的思路就是基于事先准备好的rowkey文件,利用多线程模拟并发的rowkey查询,可以实现并发数的自由控制.主要是整个流程下来,遇到了点打包的坑,所以特意记录下 ...