UINavigationController、UINavigationBa的详解和导航控制栏的定制

第一.UINavigationController的基本概念

UINavigationController是用于构建分层应用程序的主要工具,管理者多个内容视图的换入和换出,自身提供了切换的动画效果.

第二.基本样式

主要三部分:

1.导航栏:NavigationBar,在最上面,主要负责视图的弹出和控制主视图,高度是44px/32px(横过来),上面的logo是20*20px

2.内容视图,中间部分,用于显示内容

3.工具栏(UIToolBar),默认是隐藏的,用户可以自己添加工具栏,高度是44px/32px(横过来)

第三、示例代码:

 RootViewController *rootViewController=[[[RootViewController alloc] init] autorelease];
    NSLog(@"the first controller is %@",rootViewController.navigationController);
    UINavigationController *controller=[[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];
    NSLog(@"the end controller is %@",rootViewController.navigationController);


输出结果是:

2013-09-10 19:21:13.236 simpleNavigation[1841:c07] the first controller is (null)

2013-09-10 19:21:13.239 simpleNavigation[1841:c07] the end controller is <UINavigationController: 0x892eb70>

分析:
在执行,下面语句之前
 UINavigationController *controller=[[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];


rootViewController的navigatoncontroller为空,在执行了该语句之后navigationcontroller就有值了

    [self.navigationControllerpushViewController:secondVCanimated:YES];就可以实现跳转了

        [self.navigationControllersetToolbarHidden:NOanimated:YES];  //设置Toolbar是否显示

         [self.navigationControllersetNavigationBarHidden:NO]; //设置导航栏是否显示

第三UINavagitionController的代理,通过设置代理监听视图控制器的切换

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值