首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

UINavigationController的根本用法

2013-09-12 
UINavigationController的基本用法第一.UINavigationController的基本概念UINavigationController是用于构

UINavigationController的基本用法

第一.UINavigationController的基本概念

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

第二.基本样式

主要三部分:

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

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

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

第三、示例代码:

 UINavigationController *controller=[[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];

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

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

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

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

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

    self.navigationController.delegate=self;

// Called when the navigation controller shows a new top view controller via a push, pop or setting of the view controller stack.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;






热点排行