#import <UIKit/UIKit.h>

@interface RCDNavigationViewController : UINavigationController<UIGestureRecognizerDelegate,UINavigationControllerDelegate>

@end

//  .m

#import "RCDNavigationViewController.h"

@interface RCDNavigationViewController ()

@end

@implementation RCDNavigationViewController

- (void)viewDidLoad {

[super viewDidLoad];

__weak RCDNavigationViewController *weakSelf = self;

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

self.interactivePopGestureRecognizer.delegate = weakSelf;

self.delegate = weakSelf;

self.interactivePopGestureRecognizer.enabled = YES;

}

}

- (void)pushViewController:(UIViewController *)viewController

animated:(BOOL)animated {

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)] &&

animated == YES) {

self.interactivePopGestureRecognizer.enabled = NO;

}

[super pushViewController:viewController animated:animated];

}

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated {

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)] &&

animated == YES) {

self.interactivePopGestureRecognizer.enabled = NO;

}

return [super popToRootViewControllerAnimated:animated];

}

- (NSArray *)popToViewController:(UIViewController *)viewController

animated:(BOOL)animated {

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

self.interactivePopGestureRecognizer.enabled = NO;

}

return [super popToViewController:viewController animated:animated];

}

#pragma mark UINavigationControllerDelegate

- (void)navigationController:(UINavigationController *)navigationController

didShowViewController:(UIViewController *)viewController

animated:(BOOL)animate {

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

self.interactivePopGestureRecognizer.enabled = YES;

}

}

//UIGestureRecognizerDelegate

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {

if ([gestureRecognizer isEqual:self.interactivePopGestureRecognizer] &&

self.viewControllers.count > 1 &&

[self.visibleViewController isEqual:[self.viewControllers lastObject]]) {

//判断当导航堆栈中存在页面,并且 可见视图 如果不是导航堆栈中的最后一个视图时,就会屏蔽掉滑动返回的手势。此设置是为了避免页面滑动返回时因动画存在延迟所导致的卡死。

return YES;

} else {

return NO;

}

}

@end

BaseNavigationController自定义导航栏的更多相关文章

  1. 分别用ToolBar和自定义导航栏实现沉浸式状态栏

    一.ToolBar 1.在build.gradle中添加依赖,例如: compile 'com.android.support:appcompat-v7:23.4.0' 2.去掉应用的ActionBa ...

  2. swift 自定义导航栏颜色

    func setNavigationApperance(){ //自定义导航栏颜色 [self.navigationController?.navigationBar.barTintColor = U ...

  3. ios7以上自定义导航栏标题的字体大小及颜色的方法

    自定义导航栏的字体和颜色,只需要自定义一个lable,然后将lable添加到导航栏的titleview中就可以了 代码如下 UILabel *label = [[UILabel alloc] init ...

  4. iOS 自定义导航栏笔记

    一.UINavigationBar的结构 导航栏几乎是每个页面都会碰到的问题,一般两种处理方式:1.隐藏掉不显示 2.自定义 1. 添加导航栏 TestViewController * mainVC ...

  5. 微信小程序自定义导航栏

    微信小程序需要自定义导航栏,特别是左上角的自定义设置,可以设置返回按钮,菜单按钮,配置如下: 1.在app.json的window属性中增加: navigationStyle:custom 顶部导航栏 ...

  6. iOS:自定义导航栏,随着tableView滚动显示和隐藏

    自定义导航栏,随着tableView滚动显示和隐藏 一.介绍 自定义导航栏是APP中很常用的一个功能,通过自定义可以灵活的实现动画隐藏和显示效果.虽然处理系统的导航栏也可以实现,但是这个是有弊端的,因 ...

  7. 微信小程序 - 自定义导航栏(提示)

    点击下载: 自定义导航栏示例

  8. 微信小程序——自定义导航栏

    微信头部导航栏可能通过json配置: 但是有时候我们项目需求可能需要自定义头部导航栏,如下图所示: 现在具体说一下实现步骤及方法: 步骤: 1.在 app.json 里面把 "navigat ...

  9. 微信小程序-如何自定义导航栏(navigationStyle)?

    小程序是越来越开放了,微信版本 6.6.0可以自定义导航? 先了解下app.json中window配置navigationStyle属性,即导航栏样式,仅支持 default/custom.custo ...

随机推荐

  1. 2014.2.23 datagridview显示图片的方法

    DataTable dt = new DataTable(); dt.Columns.Add("", typeof(byte[])); dt.Rows.Add(File.ReadA ...

  2. JavaScript中给对象添加方法

    在JavaScript中,我们经常要给已定义的对象添加一些方法,如下:    function circle(w,h){      this.width=w;      this.height=h; ...

  3. 怎样增加phpmyadmin导入文件上限

    1 2 3 分步阅读 百度经验:jingyan.baidu.com phpMyAdmin 是一个用PHP编写的,可以通过 web 方式控制和操作 MySQL 数据库.因为操作简单被广大的使用mysql ...

  4. Hadoop YARN: 1/1 local-dirs are bad: /var/lib/hadoop-yarn/cache/yarn/nm-local-dir; 1/1 log-dirs are bad: /var/log/hadoop-yarn/containers hdfs硬盘90% yarn unhealthy

    1/1 local-dirs are bad: /var/lib/hadoop-yarn/cache/yarn/nm-local-dir; 1/1 log-dirs are bad: /var/log ...

  5. python爬虫(7)--Beautiful Soup的用法

    1.Beautiful Soup简介 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据. Beautiful Soup提供一些简单的.python式的函数用来 ...

  6. 2018网络预选赛 青岛 H

    题目链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041156323504345088 题意:小明从某一点出发,向右方 ...

  7. Python 网络爬虫 001 (科普) 网络爬虫简介

    Python 网络爬虫 001 (科普) 网络爬虫简介 1. 网络爬虫是干什么的 我举几个生活中的例子: 例子一: 我平时会将 学到的知识 和 积累的经验 写成博客发送到CSDN博客网站上,那么对于我 ...

  8. 3DPDF是个什么东西?

    就是可以把3D模型放入到PDF中,然后客户可以直接用adobe reader查看这个PDF.经过搜索发现,大多数PDF编辑软件都没有直接把3D模型插入到PDF中的功能. 很多是3D软件自身提供的,比如 ...

  9. NDIS中间层驱动实现截获数据包、包过滤功能

    1.包截获功能 http://wenku.baidu.com/view/43960751f01dc281e53af055.html 2.包过滤功能 http://wenku.baidu.com/lin ...

  10. try-catch-finally 规则( 异常处理语句的语法规则 )

    1)  必须在 try 之后添加 catch 或 finally 块.try 块后可同时接 catch 和 finally 块,但至少有一个块. 2) 必须遵循块顺序:若代码同时使用 catch 和 ...