UINavigationController与UITabBarController相关问题

UINavigationController与UITabBarController混用是非常常见的,有时候会遇到UINavigationController推出(push)出controller后隐藏UITabBarController的问题,很容易对吧.

源码如下:

//
// AppDelegate.m
// NavigationController
//
// Copyright (c) 2014年 Y.X. All rights reserved.
// #import "AppDelegate.h"
#import "RootViewController.h" #define CreateNavigationControllerWith(controller) \
[[UINavigationController alloc] initWithRootViewController:controller] @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // 初始化导航栏控制器
UINavigationController *newProductNC = \
CreateNavigationControllerWith([RootViewController new]); // 初始化TabBarController
UITabBarController *rootBC = [[UITabBarController alloc] init];
rootBC.viewControllers = @[newProductNC]; // 交给系统管理
self.window.rootViewController = rootBC; self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
} @end
//
// RootViewController.m
// NavigationController
//
// Copyright (c) 2014年 Y.X. All rights reserved.
// #import "RootViewController.h"
#import "SecondViewController.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
self.title = @"YouXianMing";
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad]; // 设定背景色
self.view.backgroundColor = [UIColor whiteColor]; // 点击手势
UITapGestureRecognizer *tapGesture = \
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(tapEvent:)]; // 添加手势
[self.view addGestureRecognizer:tapGesture];
} - (void)tapEvent:(UIGestureRecognizer *)sender
{
[self.navigationController pushViewController:[SecondViewController new]
animated:YES];
} @end
//
// SecondViewController.m
// NavigationController
//
// Copyright (c) 2014年 Y.X. All rights reserved.
// #import "SecondViewController.h" @interface SecondViewController () @end @implementation SecondViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{ }
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
} @end

效果:

将RootViewController.m中tapEvent:修改一下,如下所示:

效果(注意看底部的隐藏效果哦):

注意:隐藏与取消隐藏是成对出现的.

附录:

-修改系统颜色样式-

http://stackoverflow.com/questions/19504291/changing-the-tint-color-of-uibarbuttonitem

UINavigationController与UITabBarController相关问题的更多相关文章

  1. UIViewController、UINavigationController与UITabBarController的整合使用

    UINavigationController与UITabBarController是iOS开发中最常用的两种视图控制器,它们都属于UIViewController的子类,继承关系如下: @interf ...

  2. iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController)

    iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController)   前面我们介绍了StoryBoard这个新技术,和纯技术 ...

  3. iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController)

    iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController)   这里我们就直接上实例: 一:新建一个项目singleV ...

  4. iOS开发——实战OC篇&环境搭建之StoryBoard(玩转UINavigationController与UITabBarController)

      环境搭建之StoryBoard(玩转UINavigationController与UITabBarController)   研究了这么就IOS开发,都没有所处一个像样或者自己忙一点的项目.最近自 ...

  5. UINavigationController和UITabBarController

    UINavigationController和UITabBarController 目录 概述 UINavigationController UITabBarController 实用功能 待解决 概 ...

  6. UINavigationController与UITabbarController的样式

    之前虽然也手写过这两中视图控制器,但是更多的还是使用SB来创建,最近发现了一些问题,现在总结一下. 1.改变UINavigationBar的颜色 在UINavigationController中,之前 ...

  7. UINavigationController 与 UITabBarController

    http://www.cnblogs.com/YouXianMing/p/3756904.html // index start from 1. UITabBarItem *newsItem = [[ ...

  8. UINavigationController  和 UITabBarController

    UINavigationController当设置根控制器的时候,意思就是把根控制器压入栈内,当我们push的时候,我们把下一个控制器压入栈内,当我们pop的时候把上面的控制器的内存释放   UITa ...

  9. UINavigationController和UITabBarController合用

    一.创建一个 Tabbed Application.默认创建的是带有两个Tab的工程. 二.在AppDelegate.h里面添加 @property (strong, nonatomic) UINav ...

随机推荐

  1. svn合并分支到主干

    将分支pear_For2.3的最终版本合并到主干pear,操作步骤如下:1.选中主干pear右击-> Team -> 合并,弹出如下所示: 到此分支合并到主干已完成,若代码有冲突需找到冲突 ...

  2. tomcat启动(二)org.apache.catalina.startup.Bootstrap分析

    /** * Bootstrap loader for Catalina. This application constructs a class loader * for use in loading ...

  3. windows10下找回照片查看器的方法(仅作记录)

    Windows Registry Editor Version 5.00 ; Change Extension's File Type [HKEY_CURRENT_USER\Software\Clas ...

  4. Linux 文件内容查看工具介绍-cat,less,more,tail,head

    Linux 文件内容查看工具介绍 作者:北南南北来自:LinuxSir.Org摘要: 本文讲述几种常用文件内容的查看工具,比如cat.more.less.head.tail等,把这些工具最常用的参数. ...

  5. 关于发布程序之后js文件存在缓存问题

    把js文件加上版本号即可解决 如: <script src="../Static/js/Contract/ContractRateEdit.js?t=20181210"> ...

  6. SQL存储过程基础语法及实例

    1.定义变量简单赋值 declare @a int //声明一个变量a 赋初值为5 print @a //输出变量a 2.创建临时表 if OBJECT_ID('tempdb.#FlightState ...

  7. Codeforces 750 F:New Year and Finding Roots

    传送门 首先如果一开始就找到了一个叶子,那么暴力去递归找它的父亲,每次随机一个方向(除了已知的儿子)走深度次,如果走到了一个叶子就不是这个方向 (设根的深度为 \(1\))这样子最后到达深度为 \(3 ...

  8. JS基础(三)

    25.使用JS操作CSS样式 DHTML表示动态HTML(Dynamic HTML,DHTML),不是标记语言,只是一种由微软提出的网页脚本化概念,目标是结合JS+HTML+CSS设计动态特效,得到很 ...

  9. jQuery基础(样式篇,DOM对象,选择器,属性样式)

      1. $(document).ready 的作用是等页面的文档(document)中的节点都加载完毕后,再执行后续的代码,因为我们在执行代码的时候,可能会依赖页面的某一个元素,我们要确保这个元素真 ...

  10. Linux kernel pwn notes(内核漏洞利用学习)

    前言 对这段时间学习的 linux 内核中的一些简单的利用技术做一个记录,如有差错,请见谅. 相关的文件 https://gitee.com/hac425/kernel_ctf 相关引用已在文中进行了 ...