UINavigationController(导航控制器)
什么是导航条:
导航条不仅仅是视图的顶部,而是整个界面,导航控制器必须依赖视图存在,而顶部的条是NavigationBar(导航条),它只是导航控制器的一部分.
创建导航控制器:
//给自己添加导航控制器
FirstViewController *view = [[FirstViewController alloc]init];
UINavigationController *nav = [[UINavigationColler alloc]initWithRootViewController:view];
[self.view addSubView:view];
#pragram mark----两者之间的不同之处
/*
present方法跳转是在没有导航控制器的页面进行跳转,present也可以跳转到有导航栏的页面
push方法只支持导航控制器页面跳转到另一个导航页面(跳转的页面有默认导航条,导航条可以隐藏,但该页面还是归导航控制器管理),如果想跳转到没有导航页面的视图要使用present
*/
//没有导航控制器的页面间的跳转
[self presentViewController:otherView animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];
[self.navigationController pushViewController:nextView animated:YES];
[self.navigationController popViewControllerAnimated:YES];
两种炫酷的导航栏属性
//点击屏幕,导航条隐藏,再次点击,导航栏出现
self.navigationController.hidesBarsOnTap = YES;
//隐藏导航条
self.navigationController.navigationBar.hidden = YES;