1.创建一个UINavigationController

self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

FirstViewController * first = [[FirstViewController alloc]init];

UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:first];  UINavigationController第一个显示的界面

self.window.rootViewController = nav;

[self.window makeKeyAndVisible];

2.隐藏导航栏工具栏

self.navigationController.navigationBarHidden = YES;

self.navigationController.toolbarHidden = NO;

3.设置导航栏和工具栏的颜色(设置了之后所有都是这个颜色,因为只有一个navigationController)

self.navigationController.toolbar.barTintColor = [UIColor redColor];

self.navigationController.navigationBar.barTintColor = [UIColor redColor];

4.设置左右显示的按钮

UIBarButtonItem * leftBtn = [[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleDone target:nil action:nil];

self.navigationItem.leftBarButtonItem = leftBtn;

self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];

UIBarButtonItem * rightBtn = [[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStyleDone target:self action:@selector(gotoSecondView)];

self.navigationItem.rightBarButtonItem = rightBtn;

self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];

5.设置标题

self.navigationItem.title =@"标题";

6.标题位置设置成view

UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];

view.backgroundColor = [UIColor yellowColor];

self.navigationItem.titleView = view;

7.Next按钮响应第二个界面

-(void)gotoSecondView{

SecondViewController * svc = [[SecondViewController alloc]init];

//设置默认提供的返回按钮的标题

UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:nil action:nil];

self.navigationItem.backBarButtonItem = backItem;

//present:在现有的界面上盖上一层 dismissViewController来消除

//[self.navigationController presentViewController:svc animated:YES completion:nil];

//push:push入栈 pop出栈来消除

[self.navigationController pushViewController:svc animated:YES];

}

0129——UINavigationController的更多相关文章

  1. iOS UINavigationController(内容根据iOS编程编写)

    我们知道 UITabBarController 对象,可以通过使用该对象,用户可以切换不同的屏幕.当要切换的各个屏幕之间没有相互依存关系的时候,该对象可以很好的完成任务.但是当多个屏幕互有关系的时候, ...

  2. UINavigationController

    知识点: 1)UINavigationController 2)UINavigationBar 3)UINavigationItem 4)UIToolBar ===================== ...

  3. 混合使用UITabBarController和UINavigationController

    混合使用这两个控件的好处是我们可以在NavigationBar添加更多的东西,如标题,按钮等.让用户能够获得更多的信息. UITabBarController的属性ViewControllers接受以 ...

  4. 基本组件的使用——UINavigationController

    作用:在多个ViewController中切换.UINavigationController内部以栈的形式维护一组ViewController, 因此,当导航进入一个新视图的时候,会以push的形式将 ...

  5. 解决UINavigationController在pushViewController时出现的"卡顿"问题

    进行开发中,遇到了个小问题: 在使用UINavigationController的-pushViewController:animated:执行入栈一个子控制器操作时(即最新栈顶子控制器),会出现推出 ...

  6. UINavigationController导航控制器初始化 导航控制器栈的push和pop跳转理解

    (1)导航控制器初始化的时候一般都有一个根视图控制器,导航控制器相当于一个栈,里面装的是视图控制器,最先进去的在最下面,最后进去的在最上面.在最上面的那个视图控制器的视图就是这个导航控制器对外展示的界 ...

  7. IOS 学习 开发 自定义 UINavigationController 导航

    文件目录如下:基本导航顺序: root -> First -> Second -> Third.其中,FirstViewController作为 navigation堆栈的rootv ...

  8. APP标配控制器:UINavigationController

    导航控制器UINavigationController简介: 只要看到控制器界面上部有一个条就是导航控制器UINavigationController 导航控制器最上面有一个条是导航条高度44,Y值是 ...

  9. UIScrollerView遇到UINavigationController

    今天在UITabBarController  的第一个Tab 页面中放入一个ScrollView, 原本以为可以正常运行. 结果却让人大跌眼镜.  每当我手动滚动或者 缓慢导航到另外一个页面时,当前的 ...

随机推荐

  1. C#--virtual,abstract,override,new,sealed

    virtual:使用此关键字,可以使其在派生类中被重写. abstract:抽象方法,由子类重写,或继续为抽象方法存在,并由其子子类实现. override: 重写父类方法,属性,或事件的抽象实现或虚 ...

  2. Linux 编译安装httpsqs

    wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gz tar zxvf libevent-2.0.12-stab ...

  3. DOM 之Range(范围)

    -------<javascript高级程序设计>  12.4 范围  笔记------- DOM2级在Document类型中定义了createRange()方法,在兼容DOM的浏览器中, ...

  4. C++ Primer 5th 第3章 字符串、向量和数组

    *****代码在Debian g++ 5.40 / clang++ 3.8(C++11)下编写调试***** 本章主要是关于字符串.数组的内容,以及一些简单的容器知识. 1.using的声明 usin ...

  5. C++ Primer 5th 第2章 变量和基本类型

    *****代码在Debian g++ 5.3.1 / clang++ 3.8(C++11)下编写调试***** 由于部分编译器对标准遵循的不同以及自身额外的扩展,本章书中的少数知识点与实际实现存在偏差 ...

  6. php 获取网站根目录的写法

    路径方式,代码如下: define('BASE_PATH',str_replace('\\','/',realpath(dirname(__FILE__).'/'))."/"); ...

  7. 棋盘上的距离 - Grids1657

    棋盘上的距离 问题描述: 写一个程序,给定起始位置和目标位置,计算王.后.车.象从起始位置走到目标位置所需的最少步数. 王:横.直.斜都可以走,但每步限走一格. 后:横.直.斜都可以走,每步格数不受限 ...

  8. nsfocus-笔试题

    1.描述sendmail原理及通讯机制 sendmail程序接受到待发邮件后,通过关键字@判断邮件的格式是否符合要求,匹配成功后提取邮件后缀域名信息并查询DNS数据库相关MX(邮件专用)记录,若有匹配 ...

  9. C 语言简历一个文件夹 并自己输入字符 来取文件夹名字

    int main(void) { FILE *fp; char ch,filename[10]; scanf("%s",filename); if((fp=fopen(filena ...

  10. Selenium2Library+ride学习笔记

    一.环境部署 1.安装python2.7编译环境.ride环境以及Selenium2Library环境,环境部署可参见前面几节. 2.启动RIDE编译环境,导入Selenium2Library库.   ...