#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. 11-28 网页基础--JavaScript(DOM)

    网页基础 第二部分--HTMLDOM操作 一.定义:htmlDOM是一种面向对象的树的模型,它包含html中的所有元素:通过html可以找到所有包含在dom中的元素. 二.作用: 1.查找html元素 ...

  2. Django之时区

    在settings.py中修改如下配置: TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = False 这样在m ...

  3. Linux-CentOS 学习的坎坷路 (一) 网络配置篇

    自己学习的地址:http://www.imooc.com/view/175 学到2.8章节,配置IP这一块,妈蛋,他直接跳过了,都不知道怎么配置,无奈,只能Search 先是找到配置IP的方法: ht ...

  4. 8-EasyNetQ之Send & Receive

    鉴于Publish/Subsrcibe和Request/Response模式是位置透明的,在这个方面,你不需要去指定消息的消费者具体所处的位置,Send/Receive模式是特别针对通过命名队列来设计 ...

  5. adb pull 和 adb push

    1. 操作单个文件 通过adb push,则可将文件添加到SD卡中.如果想在push的时候修改文件名称的话,只需要修改push的第二个参数改成完整路径(目录+文件名),如/sdcard/test-0. ...

  6. 未找到与约束contractname Microsoft.VisualStudio.Utilities.IContentTypeRegistryService...匹配的导出

    ***以下操作后一定要重启VS,重启VS,重启VS重要的事情说三遍*** //************************************************************* ...

  7. 根据/proc/meminfo对空闲内存进行占用

    #include <stdio.h> #include <sys/sysinfo.h> #include <linux/kernel.h> /* 包含sysinfo ...

  8. Select2下拉选项库 部分积累

    用了这么久的Select2插件,也该写篇文章总结总结. 在我的印象里Select2有2个版本,最新版本有一些新的特性,并且更新了一下方法参数,比最初版本要好看一些,本文针对新版本. 官网:http:/ ...

  9. 【总结整理】WebGIS学习-thinkGIS(三):关于影像金字塔、瓦片行列号、分辨率resolution

    http://www.thinkgis.cn/topic/541a5206da8db186fd0673ba 1.前言 在上一节中我们知道了屏幕上一像素等于实际中多少单位长度(米或经纬度)的换算方法,而 ...

  10. 基于IFC的施工过程模拟程序(4D BIM)