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. D02 TED Elon Mulsk The future we're building — and boring

    摘要:精选TED. 每个音频不超过2分钟,学英语和吸收伟大思想两不误 音频: https://n1audio.hjfile.cn/st/de745862-d5f4-4ef4-9218-d79361ca ...

  2. Tomcat配置(二):tomcat配置文件server.xml详解和部署简介

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  3. JavaScript实现段落文本高亮

    代码: <!doctype html> <html lang="en"> <head> <meta http-equiv="Co ...

  4. .NET 绝对路径的配置

    有时候因为用IIS配置网站,会导致一些全局引用有路径问题无法引用到.今天就说一下,关于全局引用的绝对路径的配置,譬如,由于IIS配置的虚拟路径,一些CSS,JS的引用找不到,又或者自定义的一些跳转出现 ...

  5. rabbitmq配置镜像模式

    学习是spring cloud的时候用到了rabbitmq,在实际项目中也用到了,镜像模式是集群的基础上面配置的,就多了一个数据同步,rabbitmq存储消息用的是cookie,配置之前先同步cook ...

  6. iOS 获取当前应用的信息以及用户信息:版本号手机号手机型号

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; CFShow(infoDictionary); // ap ...

  7. Python学习日记:day5-------dict字典

    #字典dict------->唯一的映射类型 1.数据类型的划分 数据类型划分为可变数据类型和不可变数据类型. 不可变数据类型:tupe(元组).bool.int.str           可 ...

  8. Hawk原理:通过IEnumerable实现通用的ETL管道

    针对IEnumerable已经有多篇文章,本篇介绍如何使用IEnumerable实现ETL. ETL,是英文 Extract-Transform-Load 的缩写,用来描述将数据从来源端经过萃取(ex ...

  9. bzoj 3142: [Hnoi2013]数列

    Description 小T最近在学着买股票,他得到内部消息:F公司的股票将会疯涨.股票每天的价格已知是正整数,并且由于客观上的原因,最多只能为N.在疯涨的K天中小T观察到:除第一天外每天的股价都比前 ...

  10. iOS学习—— UINavigationController的返回按钮与侧滑返回手势的研究

    侧滑返回手势是从iOS7开始增加的一个返回操作,经历了两年时间估计iPhone用户大部分都已经忽略了屏幕左上角那个碍眼的back按钮了.之前在网上搜过有关侧滑手势的技术博客,发现大多比较散乱,甚至有很 ...