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. 机器学习--Gradient Boosting Machine(GBM)调参方法详解

    一.GBM参数 总的来说GBM的参数可以被归为三类: 树参数:调节模型中每个决策树的性质 Boosting参数:调节模型中boosting的操作 其他模型参数:调节模型总体的各项运作 1.树参数 现在 ...

  2. Nodejs学习笔记(五)—Express安装入门与模版引擎ejs

    前言 前面也学习了一些Node.js的基本入门知道,现在开始进入Web开发的部分: Node.js提供了http模块,这个模块中提供了一些底层接口,可以直接使用,但是直接开发网站那还是太累了,所以ht ...

  3. 发布Framework 4.0到iis时,出现HTTP 错误 403.14 - Forbidden

    新发布MVC到服务器的时候,经常碰到403.14错误,绝大部分的时候都是因为Framework 4.0需要重新注册下,在运行里输入:C:\Windows\Microsoft.NET\Framework ...

  4. Maven 设置阿里巴巴发布版本仓库

    打开 pom.xml 在里面添加以下代码就能顺利在阿里上面下载所需要的 jar 包文件: <!--设置 Maven 组件仓库 --> <repositories> <!- ...

  5. C# 接口用法

    一.接口定义 接口是指一组函数成员而不实现它们的引用类型,只能由类和结构来是实现,接口的作用就不阐述了 二.声明接口 interface IMyInterface //interface 是关键字,后 ...

  6. Ionic3 UI组件之 ImageViewer

    组件特性: 轻触图片可全屏查看 手势上下滑动可关闭全屏查看 点击导航箭头可关闭视图 双击查看全图,并可放大 参考地址:https://github.com/Riron/ionic-img-viewer ...

  7. vue基于d2-admin的RBAC权限管理解决方案

    前两篇关于vue权限路由文章的填坑,说了一堆理论,是时候操作一波了. vue权限路由实现方式总结 vue权限路由实现方式总结二 选择d2-admin是因为element-ui的相关开源项目里,d2-a ...

  8. 我所了解的Hibernate注解

    一,首先需要导入支持注解开发的jar包: hibernate-annotations.jar hibernate-commons-annotations.jar (Hibernate中支持注解开发的j ...

  9. FacebookFriendAdderPro

    Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Fe ...

  10. Linux系统修改Mysql密码

    一.拥有原来的myql的root的密码: 方法一: 在mysql系统外,使用mysqladmin mysqladmin -u root -p password "test123" ...