UINavigationController与UITabBarController相关问题
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相关问题的更多相关文章
- UIViewController、UINavigationController与UITabBarController的整合使用
UINavigationController与UITabBarController是iOS开发中最常用的两种视图控制器,它们都属于UIViewController的子类,继承关系如下: @interf ...
- iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController)
iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController) 前面我们介绍了StoryBoard这个新技术,和纯技术 ...
- iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController)
iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController) 这里我们就直接上实例: 一:新建一个项目singleV ...
- iOS开发——实战OC篇&环境搭建之StoryBoard(玩转UINavigationController与UITabBarController)
环境搭建之StoryBoard(玩转UINavigationController与UITabBarController) 研究了这么就IOS开发,都没有所处一个像样或者自己忙一点的项目.最近自 ...
- UINavigationController和UITabBarController
UINavigationController和UITabBarController 目录 概述 UINavigationController UITabBarController 实用功能 待解决 概 ...
- UINavigationController与UITabbarController的样式
之前虽然也手写过这两中视图控制器,但是更多的还是使用SB来创建,最近发现了一些问题,现在总结一下. 1.改变UINavigationBar的颜色 在UINavigationController中,之前 ...
- UINavigationController 与 UITabBarController
http://www.cnblogs.com/YouXianMing/p/3756904.html // index start from 1. UITabBarItem *newsItem = [[ ...
- UINavigationController 和 UITabBarController
UINavigationController当设置根控制器的时候,意思就是把根控制器压入栈内,当我们push的时候,我们把下一个控制器压入栈内,当我们pop的时候把上面的控制器的内存释放 UITa ...
- UINavigationController和UITabBarController合用
一.创建一个 Tabbed Application.默认创建的是带有两个Tab的工程. 二.在AppDelegate.h里面添加 @property (strong, nonatomic) UINav ...
随机推荐
- java获得当前日期是今年的第几周,以及这周的开始日期的方法
直接上代码,备份使用 时间戳,长整型存储 long startTime1 = 1530613938532l; Calendar cale ...
- elasticsearch(二) 之 elasticsearch安装
目录 elasticsearch 安装与配置 安装java 安装elastcsearch 二进制安装(tar包) 在进入生产之前我们必须要考虑到以下设置 增大打开文件句柄数量 禁用虚拟内存 合适配置的 ...
- Jquery的toggle()方法
toggle()并不是仅仅能 显示/隐藏而已 它的格式如下 toggle(fn1,fn2,fn3.....) 也就是说,它的参数可以说不定数目的 若干个方法,然后每个方法按顺序轮番调用 $(docum ...
- lucene源码分析(5)lucence-group
1. 普通查询的用法 org.apache.lucene.search.IndexSearcher public void search(Query query, Collector results) ...
- Linux内核编程规范与代码风格
source: https://www.kernel.org/doc/html/latest/process/coding-style.html translated by trav, travmym ...
- 【eclipse修改默认注释】
一.背景简介 丰富的注释和良好的代码规范,对于代码的阅读性和可维护性起着至关重要的作用.几乎每个公司对这的要求还是比较严格的,往往会形成自己的一套编码规范.但是再实施过程中,如果全靠手动完成,不仅效率 ...
- APICloud APP前端框架——手机APP开发、APP制作、APP定制平台
概述 APICloud前端框架,包括api.js和api.css.api.css处理不同平台浏览器的默认样式.api.js是一个JavaScript库.是APICloud为混合移动开发定制的轻量Jav ...
- vs中插件影响代码自动创建后台事件问题
CSS Tools 启用之后会影响代码自动创建后台事件,禁用之后解决.禁用之后鼠标悬浮不能看图片,颜色也不能展示
- wcf读写cookie
一般来说,web应用的服务端(aspx或mvc的action)调用wcf时,是一个服务与服务的通讯,而不是客户端(浏览器)与服务器的通讯. 这种情况下,如果要在wcf端处理客户端的cookie,就需要 ...
- 【转】Stack Overflow研发副总裁:.NET技术并不差,合适自己就好
摘要:在QCon纽约大会上, Stack Exchange的工程部副总裁David Fullerton深入解析了如何使用C#.MS SQL等技术支撑Stack Overflow网站的单块应用架构,这个 ...