#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. react-router4.x 组件和api介绍

    react-router实用4.2.0 react-router非常复杂整体,比vue-router强大很多,好好研究,对你自身能力提高很有帮助 安装 cnpm install react-route ...

  2. docker 笔记 (5)常用命令

    images    显示镜像列表 history   显示镜像构建历史 commit    从容器创建新镜像 build     从 Dockerfile 构建镜像 tag       给镜像打 ta ...

  3. 部署和调优 1.1 nfs部署和优化-2

    更改共享目录文件默认的所有者和所属组 已知道客户端有个user11用户 cat /etc/passwd user11:x:501:501::/home/user11:/bin/bash 服务端打开 v ...

  4. 获取iframe自适应后的宽高

    1.同域 一:引入jquery <script type="text/javascript" src="../jquery.min.js">< ...

  5. 10.model/view实例(2)

    任务:显示一个2x3的表格,将表格中的数据显示如下: 思考: 1.如何显示数据和上个例子一样. 2.但是每个单元格的数据都是有角色划分的. Qt::ItemDataRole 3.View从Model中 ...

  6. 数据结构 happiness

    问题描述 这一天是小 V 的生日,他收到了朋友们送给他的礼物.现在,小 V 有 n 件礼物,他将这 n 件礼物排成一排,依次编号为 1 到 n,每件礼物都有一个满意值 w[i].现在小 V 要从中选取 ...

  7. Spring第一篇

    我计划用3到五篇文章来描述Spring,这是第一篇 1 . 什么是Spring Spring 是一个开源框架,Spring 是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnso ...

  8. 发现C#winform编程中不常用的控件(一)<FlowLayoutPanel控件><拆分器控件Splitcontainer >

    第一部分:FlowLayoutPanel控件 实现效果: 将FlowLayoutPanel做为导航菜单按钮的容器 以实现 某个菜单按钮不显示时 整体的导航菜单布局不至于"缺憾" 原 ...

  9. [译]Javascript数列filter方法

    本文翻译youtube上的up主kudvenkat的javascript tutorial播放单 源地址在此: https://www.youtube.com/watch?v=PMsVM7rjupU& ...

  10. 后台调js方法

    Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>btnSearch( ...