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 应用全部添加滑动返回的更多相关文章

  1. 再谈iOS 7的手势滑动返回功能

    本文转载至 http://blog.csdn.net/jasonblog/article/details/28282147  之前随手写过一篇<使用UIScreenEdgePanGestureR ...

  2. iOS 7的手势滑动返回

    如今使用默认模板创建的iOS App都支持手势返回功能,假设导航栏的返回button是自己定义的那么则会失效,也能够參考这里手动设置无效. if ([self.navigationController ...

  3. iOS开发解决页面滑动返回跟scrollView左右划冲突

    -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithG ...

  4. iOS 如何设置导航的滑动返回手势, 和系统饿一样

    iOS 7 滑动返回那些事儿 2014/05/17 Wei .entry-meta .entry-header 在智能机越来越普及,屏幕越做越大的当下,滑动返回手势已经成为了一个应用的标配功能,甚至可 ...

  5. 类似IOS的滑动返回上一级,SwipeBackLayout-android的滑动返回类库

    最近,公司在开发App的需求中增加了一个新的需求,要在android的页面中增加向右滑动的时候返回上一级页面.我刚知道这个需求的时候,感觉有点坑,可能设计那边最近接触到知乎的客户端或者是IOS的滑动可 ...

  6. iOS开发——实用技术OC篇&8行代码教你搞定导航控制器全屏滑动返回效果

    8行代码教你搞定导航控制器全屏滑动返回效果 前言 如果自定了导航控制器的自控制器的leftBarButtonItem,可能会引发边缘滑动pop效果的失灵,是由于 self.interactivePop ...

  7. iOS之手势滑动返回功能-b

    iOS中如果不自定义UINavigationBar,通过手势向右滑是可以实现返回的,这时左边的标题文字提示的是上一个ViewController的标题,如果需要把文字改为简约风格,例如弄过箭头返回啥的 ...

  8. iOS之手势滑动返回功能

    iOS中如果不自定义UINavigationBar,通过手势向右滑是可以实现返回的,这时左边的标题文字提示的是上一个ViewController的标题,如果需要把文字改为简约风格,例如弄过箭头返回啥的 ...

  9. iOS 自定义返回按钮,保留系统滑动返回

    原文链接 自定义返回按钮保留系统滑动返回手势.gif 1.简介 使用苹果手机,最喜欢的就是用它的滑动返回.作为一个开发者,我们在编写很多页面的时候,总是会因为这样那样的原因使得系统的滑动返回不可用.使 ...

随机推荐

  1. bootstarp模板02

    HTML代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="ut ...

  2. Orchard Core Framework:ASP.NET Core 模块化,多租户框架

    Orchard Core Framework:ASP.NET Core 模块化,多租户框架 上一篇编写Orchard Core一分钟搭建ASP.NET Core CMS ,介绍ASP.NET Core ...

  3. 大白话Vue源码系列(04):生成render函数

    阅读目录 优化 AST 生成 render 函数 小结 本来以为 Vue 的编译器模块比较好欺负,结果发现并没有那么简单.每一种语法指令都要考虑到,处理起来相当复杂.上篇已经生成了 AST,本篇依然对 ...

  4. 「mysql优化专题」视图应用竟然还可以这么优化?不得不收藏(8)

    一.视图概述(技术文): (1)什么是视图? 视图是基于 SQL 语句的结果集的可视化的表. 视图包含行和列,就像一个真实的表.视图中的字段就是来自一个或多个数据库中的真实的表中的字段.视图并不在数据 ...

  5. django+Echarts实现数据可视化

    1.实时异步加载(从mysql读取数据) 2.scatter散点图 3.雷达图(参数选择要注意) time_1 time_2 time_3 4.面积图 我上传的源码请到github下载:https:/ ...

  6. java表单重复提交常用解决办法

    最近在看些基础的东西,顺便做下笔记.相信大家在平时网页使用中,经常会有按钮重复点击,然后点不动刷新,还有当网络延时比较厉害点了没反应在点击的重复提交.为了避免这种情况,总结了一下4点处理方案 表单重复 ...

  7. 【java设计模式】【创建模式Creational Pattern】工厂方法模式Factory Method Pattern(多态性工厂模式Polymorphic Factory Pattern、虚拟构造子模式Virtual Constructor Pattern)

    public class Test { public static void main(String[] args){ Creator ca=new ConcreteCreatorA(); ca.cr ...

  8. JavaScript基础4——关于语句流程控制(分支语句、循环语句等)

    分支语句 (1)if...else...语句,基本格式分三种,如下 <script type="text/javascript"> var i=50; //if语句 i ...

  9. 函数的非固定参数-Day3

    一.函数非固定参数 1.默认函数,我们在传参之前,选给参数指定一个默认的值.默认参数特点是非必须传递的. def test(x,y=2): print(x) print(y) print(" ...

  10. RabbitMQ阻塞读取时数据时,关闭channel引起的问题和解决方案

    项目场景: 最近在项目中使用了RabbitMq,其中有一个功能必须能随时切断RabbitMq的coumser.第一时间写出来的代码如下: 伪代码: while(flag){ QueueingConsu ...