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. [Leetcode][020] Valid Parentheses (Java)

    题目在这里: https://leetcode.com/problems/valid-parentheses/ [标签]Stack; String [个人分析]这个题应该算是Stack的经典应用.先进 ...

  2. 关于ROW_NUMBER函数的使用(The use of ROW_NUMBER function )

    1.用于删除重复记录(The use of to delete the common record) 例子:(Example) #1初始化数据(Initialize the data) CREATE ...

  3. web标准(复习)--7 横向导航菜单

    今天我们开始学习html列表,包含以下内容和知识点: 横向列表菜单 用图片美化的横向导航 css Sprites 一.横向列表菜单前边学习过纵向导航菜单,又学习了float属性,那么要实现横向导航菜单 ...

  4. 求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数字

    #include <iostream> using namespace std; int main() {long long s,n,i,j,p;s=0; cin>>n;    ...

  5. While installing plugin in eclipse luna, “Unable to acquire PluginConverter service” and “No repository found” errors appear in logs

    http://stackoverflow.com/questions/18767831/while-installing-plugin-in-eclipse-luna-unable-to-acquir ...

  6. 智能卡安全机制比较系列(二)DS SmartCard

    DS Smart Card是飞利浦公司自己开发的一款CPU卡产品,在早期芯片厂商开发自己的COS并进行推广很普遍,现在像英飞凌(前西门子半导体)以及恩智普(前飞利浦半导体)几乎很少推广自己的COS,大 ...

  7. jQuery ajax方法在Chrome浏览器下失效问题

    最近做测试时碰到一个问题,chrome下使用ajax的一些方法(如get,load等)的时候完全失效: $(function() { $("#send").click(functi ...

  8. .net中除去IList中的多余项

    IList<ActionInfo> tempList = new List<ActionInfo>(); IList<ActionInfo> tempActionL ...

  9. 在OCX初始化时获取其在网页中的DOM对象

    OCX初始化的时候会调用SetClientSite,会传入IOleClientSite对象. CComQIPtr<IOleControlSite, &IID_IOleControlSit ...

  10. poj3254:基础状压dp

    第二个状压dp 做过的第一个也是放牛问题,两头牛不能相邻 这个题多了一个限制,就是有些位置不能放牛 于是先与处理一下每一行所有不能放牛的状态,处理的过程直接对每一个不能放牛的状态或以下 ac代码: # ...