以一个UINavigationController作为根视图控制器,然后通过pushViewController函数实现多级跳转,以及通过popViewControllerAnimated函数跳到上一个视图界面,popToViewController函数跳到指定视图界面,popToRootViewControllerAnimated函数跳到根视图界面。
这种情况下一般用UINavigationController作为window的跟视图控制器,并以一个ViewController作为UINavigationController的根视图控制器,这样ViewController就可以自由添加导航条并进行各种设置了,这里ViewController是一个UITableViewController:
一.导航视图UINavigationController

-(BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions{//初始化windowself.window = [[UIWindow alloc]init];// window跟屏幕一样大self.window.frame = [UIScreenmainScreen].bounds;// window背景色self.window.backgroundColor = [UIColorwhiteColor];//表格菜单MainTableViewController *mainVC =[[MainTableViewController alloc] init];//根导航UINavigationController *rootNavVC =[[UINavigationController alloc]initWithRootViewController:mainVC];//跟导航作为window的跟控制器self.window.rootViewController =rootNavVC;return YES;
}

之后在ViewController中的viewDidLoad函数中就可以添加导航栏的各种设置了,标题,按钮等:

- (void)viewDidLoad{[super viewDidLoad];//标题self.title = @"蒋信厚的Demo";//导航条按钮组件self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:selfaction:@selector(selector)];//导航栏背景色self.navigationController.navigationBar.backgroundColor = [UIColororangeColor];//导航栏按钮组件的颜色self.navigationController.navigationBar.tintColor = [UIColorredColor];//标题颜色[self.navigationController.navigationBarsetTitleTextAttributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:15],NSForegroundColorAttributeName:[UIColorwhiteColor]}];}

导航视图下的页面跳转

[self.navigationControllerpushViewController:newViewController animated:YES];// 获取当前视图控制器的index
NSInteger index= [self.navigationController.viewControllersindexOfObject:self];//根据index获取历史视图SLPatientDataController*diseaseVC= [self.navigationController.viewControllersobjectAtIndex:index-1];
[self.navigationControllerpopToViewController:diseaseVCanimated:YES];[self.navigationControllerpopToRootViewControllerAnimated:YES];

2.底部导航条UITabBarController:

典型的底部导航结构如下,UITabBarController内放置多个自定义的UINavigationController,同时将每个子页面的根视图UIViewController作为导航视图UINavigationController的rootViewController,从而实现底部导航视图的分栏导航和每一栏里面的多级跳转:

三级类的示例如下:

UITabBarController

//
//  MainTabBarController.h
//  JXHDemo
//
//  Created by Xinhou Jiang on 16/7/21.
//  Copyright © 2016年 Jiangxh. All rights reserved.
//#import <UIKit/UIKit.h>@interface MainTabBarController : UITabBarController@end
//
//  MainTabBarController.m
//  JXHDemo
//
//  Created by Xinhou Jiang on 16/7/21.
//  Copyright © 2016年 Jiangxh. All rights reserved.
//#import "MainTabBarController.h"
#import "TabNavController.h"
#import "MainTableViewController.h"
#import "FoundationViewController.h"
#import "MyDemoViewController.h"@interface MainTabBarController ()@end@implementation MainTabBarController- (void)viewDidLoad {[super viewDidLoad];// 1.UIKitMainTableViewController *uikitVC = [[MainTableViewController alloc]init];[self addTabBarChildVC:uikitVC title:@"UIKit" icon:@"tabbar_home"];// 2.FoundationFoundationViewController *foundationVC = [[FoundationViewController alloc]init];[self addTabBarChildVC:foundationVC title:@"Foundation" icon:@"tabbar_home"];// 3.DemoMyDemoViewController *demoVC = [[MyDemoViewController alloc]init];[self addTabBarChildVC:demoVC title:@"Demo" icon:@"tabbar_home"];// 底部导航栏选中后的文字颜色self.tabBar.tintColor = RGBColor(28, 190, 164);
}/***  添加tabbar子控制器*/
- (void) addTabBarChildVC:(UIViewController*)childVC title:(NSString *)title icon:(NSString *)icon {// 导航跟控制器TabNavController *navController = [[TabNavController alloc]initWithRootViewController:childVC];// 底部导航标题navController.tabBarItem.title = title;// 底部导航图标navController.tabBarItem.image = [UIImage imageNamed:icon];// 将当前子控制器添加到底部导航控制器[self addChildViewController:navController];
}@end

UINavigationController

//
//  TabNavController.h
//  JXHDemo
//
//  Created by Xinhou Jiang on 16/7/21.
//  Copyright © 2016年 Jiangxh. All rights reserved.
//#import <UIKit/UIKit.h>@interface TabNavController : UINavigationController@end
//
//  TabNavController.m
//  JXHDemo
//
//  Created by Xinhou Jiang on 16/7/21.
//  Copyright © 2016年 Jiangxh. All rights reserved.
//#import "TabNavController.h"@interface TabNavController ()@end@implementation TabNavController- (void)viewDidLoad {[super viewDidLoad];// 顶部导航栏的背景色self.navigationBar.barTintColor = RGBColor(28, 190, 164);// 导航栏标题文字颜色和大小[self.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20.0],NSForegroundColorAttributeName:[UIColor whiteColor]}];
}@end

UIViewController

自定义。

效果如下:

  

IOS底部导航设置与页面多级跳转相关推荐

  1. NIUSHOP wap端底部导航设置

    WAP端底部导航设置 底部导航(同首页导航,当你没有做到足够好的商品关联时,只要你精心设置好你的网站导航,它就可以让你店铺的各个页面串联起来,方便买家在栏目间快速切换,引导买家前往您期望的页面.) 底 ...

  2. 微信小程序自定义底部导航栏遮挡页面内容(已解决)

    今天也是努力写毕设的一天~ 这几天在实现旅行日记的笔记详情界面,先实现了自定义的底部导航栏,在这里我使用的是iView Weapp,具体的介绍我放在这里了~ 快速上手 iView Weapp 跟着里面 ...

  3. Android底部导航栏切换页面填坑

    ** Android底部导航栏切换页面填坑 ** 这个效果的实现关键点就是给选项赋予两种状态,focused和normal,在主程序中用监听判断是否被选中,就给被选中的选项设focused为true, ...

  4. 【Flutter】底部导航栏页面框架 ( BottomNavigationBar 底部导航栏 | PageView 滑动页面 | 底部导航与滑动页面关联操作 )

    文章目录 一.BottomNavigationBar 底部导航栏 二.PageView 滑动页面 三.BottomNavigationBar 与 PageView 关联 四.完整代码示例 1.核心导航 ...

  5. mui ios底部导航和顶部标题被遮挡问题

    1.iphonex底部导航兼容问题 function isIphoneX(){return /iphone/gi.test(navigator.userAgent) && (scree ...

  6. Flutter底部导航栏BottomNavigationBar页面状态保持解决方案

    网易云[玩转大前端]配套课程 EDU配套 教程 Flutter开发的点滴积累系列文章 一行代代码置灰应用?对就是这么干 在实际应用开发中,一般应用的首页面会有这种结构,在Flutter应用开发中,有多 ...

  7. 设置html页面自动跳转以及超链接基本跳转设置

    1.在html头标签中写上<meta http-equiv="refresh" content="3;url=hello.html" /> 意思为3 ...

  8. html导航栏代码跳转,微信小程序自定义底部导航栏tabBar(含跳转页面wx.navigateTo)...

    一.app.json配置 这里配置 {"pages": ["pages/usersLists/usersLists","pages/addMember ...

  9. Vue实现底部导航栏切换页面及图片

    前言 刚进新公司,有幸接触到从前后端不分离到前后端分离的一个过程,最开始对vue不太熟悉,下班自学一周就开始做了,可能会有很多问题,若有写不好的地方大佬们可以提出. 一.实现效果 需求:vue底部导航 ...

最新文章

  1. RDKit | 删除方差低的描述符
  2. 移动端图形化报表界面设计_B端移动设计 | 客户RFM分析
  3. Placement new
  4. Openfiler开启iSCSI服务(iSCSI Target)
  5. bzoj 4012: [HNOI2015]开店
  6. python模块的函数_Python模块及函数的使用
  7. firework常用快捷键
  8. lua php 触摸精灵,lua程序设计主要学习路径
  9. socket 收不到netty客户端消息_Netty开发 —— 首个demo学习
  10. c语言 大数相加,c/c++开发分享C语言计算大数相加的方法
  11. 按应用领域来划分,电话光端机主要分为哪几类
  12. CentOS7设置环境变量
  13. Scala学习(二、控制结构)
  14. 用easyx画五角星_冷军画了一把破剪刀, 竟然卖到了160万,被专家抨击:乱涂鸦!得奖后专家顿时不说话了...
  15. 移动端自动化测试:python+appium+pytest+allure+yaml
  16. ITRS/GCRS/J2000坐标系的相互转换
  17. 火灾自动报警系统下综合布线施工要素
  18. 高考倒计时100天,用python看看高三党
  19. 什么叫DMZ区?DMZ区有什么作用?应该怎样构建DMZ?
  20. 7.Python 文件I/O

热门文章

  1. linux没有root权限如何安装软件,我如何安装没有root权限的软件包?
  2. WF4.0 基础篇 (二十七) WCF Workflow Service 在WCF中使用WF
  3. Excel如何批量隐藏0值单元格整行
  4. BPR-贝叶斯个性化排序+算法
  5. chart.js 饼图显示百分比_【数据可视化.图表篇】饼图
  6. Altera RapidIO IP维护模块
  7. PDF.NET 数据开发框架
  8. Python每日学习-布尔表达式
  9. 出国程序---去体检打印成绩单
  10. 计算机课中不可计算的例子,在计算机中哪些问题不可计算