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. 武汉科技大学ACM :1001: A + B Problem

    Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to e ...

  2. 第1章 网络编程基础(3)——基本Socket通信

    服务器常用模型

  3. Java中int和String互相转换的多种方法

    1 如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Integer.parseInt([String]); 或 i = Integer.parseInt([ ...

  4. 如何使用JSONP

    1.使用$.getJSON() $.getJSON(" http://跨域的dns/document!searchJSONResult.action?name1="+value1+ ...

  5. mac下 配置tomcat

    第一步: 1.打开你的终端:然后输入  pico .bash_profile   回车 第二步: 2. 然后添加你tomcat放入的路径的path 编辑完后,control+x   (保存)    继 ...

  6. google jam 比赛题(设计有问题)

    题目: Problem Do you know how to read the phone numbers in English? Now let me tell you. For example, ...

  7. asp.net 管道模型+生命处理周期

    http://www.cnblogs.com/qianlifeng/archive/2010/12/16/1908568.html https://msdn.microsoft.com/zh-cn/l ...

  8. 【转】Date类学习总结(Calendar Date 字符串 相互转换 格式化)

    原文网址:http://www.blogjava.net/jerry-zhaoj/archive/2008/10/08/233228.html Date类学习总结 1.计算某一月份的最大天数 Cale ...

  9. Linux一个简单的读写文件

    (1)linux中的文件描述符fd的合法范围是或者一个正正数,不可能是一个负数. (2)open返回的fd程序必须记录好,以后向这个文件的所有操作都要靠这个fd去对应这个文件,最后关闭文件时也需要fd ...

  10. Python Scrapy安装杂症记录

    昨天安装了scrapy一切正常,调试了bbsSpider案例(详见上文),今日开机因为冰封还原,提示找不到python27.dll,重新安装了python2.7, 使用easy-install scr ...