1.常用属性
viewControllers //所有在栈中的控制器
topViewController //栈顶控制器
navigationBar //导航栏 竖屏下默认44,横屏默认32

2.对navigationBar的标题进行字体颜色等设置
NSDictionary *dic = @{
NSForegroundColorAttributeName:[UIColor whiteColor]
};
UIViewController.navigationBar.titleTextAttributes = dic;

3.navigation返回的设置
使用pushViewController切换到下一个视图时,navigation controller按照以下3条顺序更改导航栏的左侧按钮。

(1)、如果B视图有一个自定义的左侧按钮(leftBarButtonItem),则会显示这个自定义按钮;

(2)、如果B没有自定义按钮,但是A视图的backBarButtonItem属性有自定义项,则显示这个自定义项;

(3)、如果前2条都没有,则默认显示一个后退按钮,后退按钮的标题是A视图的标题()

4.自定义navigationBar
navigationController.navigationBar.barTintColor //导航条颜色
[navigationController.navigationBar setBackgroundImage] //导航条加背景

5.管理UINavigationItem
UINavigationBar处理能管理一组UINavigationItem

与UINavigationController相似,UINavigationBar也是以栈的方式管理一组UINavigationItem。提供push和pop操作item

每个视图控制器都有一个navigationItem属性,navigationItem中设置的做按钮、右按钮、标题等,会随着控制器的显示,也显示到navigationBar上

UINavigationItem属于MVC中的M,封装了要显示在UiNavigationBar上的数据

title: 标题
titleView :标题视图
leftBarButtonItem :左按钮
rightBarButtonItem :右按钮

6.UIBarButtonItem
-initWithBarButtonSystemItem:target:action:设置按钮样式及触发事件
-initWithTiltle:style:target:action: 设置标题的触发事件
-initWithImage:style:target:action:设置视图的触发事件
tintColor 设置tintColor可以影响添加在导航条上的系统样式的按钮的颜色
//设置一个自定义按钮
UIButton *wlButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
wlButton.backgroundColor = [UIColor yellowColor];
UIBarButtonItem *wlBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:wlButton];
self.navigationItem.rightBarButtonItem = wlBarButtonItem; (self 是一个在navigationController栈中的一个UIViewController)

7.导航栏上面提示信息
UIViewController.navigationItem.prompt = @"哈哈哈";
在几秒后消失可以加一个定时器 使 UIViewController.navigationItem.prompt = nil

8.//关闭半透明效果, 让所有的subviews起点坐标从导航栏的下方开始计算
self.navigationController.navigationBar.translucent = NO;

10.自定义navigationItem.leftBarButtonItem 时候,下面这个值为YSE则不覆盖返回按钮,默认是NO;
self.navigationItem.leftItemsSupplementBackButton = YES;

11.navigationController 和  UIScrollView 一起使用的时候一定要注意:

(1)新建一个工程,在Main.storyboard 拖一个UINavigationController设置为inital View Controller(打钩),

并把rootViewController换成一个UIViewController;

把拖进来的UIViewController Class换成ViewController

注意下面

ViewController中有一个Adjist  Scroll View Insets 默认是勾上的。

在ViewController 中创建一个scrollView,和一个topView,并把topView添加到scrollView上

- (void)viewDidLoad {
[super viewDidLoad]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
scrollView.backgroundColor = [UIColor redColor];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
topView.backgroundColor = [UIColor yellowColor]; [scrollView addSubview:topView];
[self.view addSubview:scrollView];
}

运行效果:可以看到topView(黄色)往下偏移了64(状态栏:20+导航栏:44)的高度

把Adjist  Scroll View Insets勾去掉效果如下

这是因为UIViewController有下面这个属性:

@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets NS_AVAILABLE_IOS(7_0); // Defaults to YES

代码中把这个属性置NO也可以消除对ScrollerView的影响;

12.往navigationBar 上添加图片时图片颜色显示不正确

- (void)creatNaviButton
{
UIImage *image = [UIImage imageNamed:@"ic_webview_back_normal.png"];
//保持图片颜色
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
self.navigationItem.leftBarButtonItem = leftButton; }

下面是改变所有的barbutton的颜色

[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

UINavigationController使用的注意事项的更多相关文章

  1. jQuery UI resizable使用注意事项、实时等比例拉伸及你不知道的技巧

    这篇文章总结的是我在使用resizable插件的过程中,遇到的问题及变通应用的奇思妙想. 一.resizable使用注意事项 以下是我在jsfiddle上写的测试demo:http://jsfiddl ...

  2. Windows Server 2012 NIC Teaming介绍及注意事项

    Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...

  3. TODO:Golang指针使用注意事项

    TODO:Golang指针使用注意事项 先来看简单的例子1: 输出: 1 1 例子2: 输出: 1 3 例子1是使用值传递,Add方法不会做任何改变:例子2是使用指针传递,会改变地址,从而改变地址. ...

  4. app开发外包注意事项,2017最新资讯

    我们见过很多创业者,栽在这app外包上.很多创业者对于app外包这件事情不是特别重视,以为将事情交给app外包公司就完事了,实际上不是的.无论是从选择app外包公司还是签订合同.售后维护等各方面都有许 ...

  5. favicon.ioc使用以及注意事项

    1.效果 2.使用引入方法 2.1 注意事项:(把图标命名为favicon.ico,并且放在根目录下,同时使用Link标签,多重保险) 浏览器默认使用根目录下的favicon.ico 图标(如果你并没 ...

  6. ORACLE分区表梳理系列(二)- 分区表日常维护及注意事项(红字需要留意)

    版权声明:本文发布于http://www.cnblogs.com/yumiko/,版权由Yumiko_sunny所有,欢迎转载.转载时,请在文章明显位置注明原文链接.若在未经作者同意的情况下,将本文内 ...

  7. 【原】Masonry+UIScrollView的使用注意事项

    [原]Masonry+UIScrollView的使用注意事项 本文转载请注明出处 —— polobymulberry-博客园 1.问题描述 我想实现的使用在一个UIScrollView依次添加三个UI ...

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

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

  9. 《连载 | 物联网框架ServerSuperIO教程》- 5.轮询通讯模式开发及注意事项。附:网友制作的类库说明(CHM)

    1.C#跨平台物联网通讯框架ServerSuperIO(SSIO)介绍 <连载 | 物联网框架ServerSuperIO教程>1.4种通讯模式机制. <连载 | 物联网框架Serve ...

随机推荐

  1. MySQL索引详解

    导读:大家都知道,一个MySQL数据库能够储存大量的数据,如果要查找那一个数据,就得费好大劲从一大堆的数据中找到,即费时间又费力气,这时,索引的出现就大大减轻了数据库管理员的工作.本文介绍了数据库索引 ...

  2. 关于Asp.Net Forms身份认证

    Asp.Net管道式的构建个我们提供了通过IHttpMoudle来订阅管线事件来达到干预HTTP请求的目的,Asp.Net的身份认证正是通过此种方式来对请求来执行身份认证的,这篇文章仅仅谈论Forms ...

  3. javascript 正则 验证 第25节

    <html> <head> <title>Form对象</title> <script type="text/javascript&qu ...

  4. 用Python进行语音信号处理

    1.语音信号处理之时域分析-音高追踪及其Python实现 2.语音信号处理之时域分析-音高及其Python实现 参考: 1.NumPy

  5. 常用Linux/Unix/Mac Os命令

    常用Linux/Unix/Mac OS命令 参考: 1.50 Most Frequently Used UNIX / Linux Commands (With Examples)

  6. 暑假集训(2)第六弹 ----- Frosh Week(UVA11858)

    H - Frosh Week Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     ...

  7. OCI_ERROE - errcode[1591],errmsg[ORA-01591:

    CEASYDAO: 错误码[1591],错误信息[Error - OCI_ERROE - errcode[1591],errmsg[ORA-01591: lock held by in-doubt d ...

  8. STL简介

    由于不同书籍和翻译问题对STL中的术语可能有差别本文采用侯杰<STL源码剖析>中的术语 STL的组件 包含6个组件,分别为容器.算法.迭代器.仿函数(函数对象).配接器(适配器).配置器( ...

  9. 堆排序 C++

    1 堆排序拥有插入排序的优点 (是一种原地排序算法只需要存储常数个元素在输入数组以外 即省空间), 同时拥有合并排序算法的复杂度 nlgn,逼格有点高 2 堆数据结构 是一个数组对象,可以被视为一颗完 ...

  10. 九度OJ 1442 A sequence of numbers

    题目地址:http://ac.jobdu.com/problem.php?pid=1442 题目描述: Xinlv wrote some sequences on the paper a long t ...