iOS viewController添加导航条以及返回跳转选择
给单独的viewcontroller或者在Appdelegate的主页面添加导航条,只要在viewcontroller上添加navigationcontroller,在添加此navigationcontroller即可
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
ViewController *mainView = [[ViewController alloc]init];
UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:mainView];
navi.navigationBar.backgroundColor = [UIColor blueColor];
[self.window setRootViewController:navi];
[self.window makeKeyAndVisible];
return YES;
}
self.navigationController.navigationBar.titleTextAttributes
= [NSDictionary dictionaryWithObject:[UIColor whiteColor]
forKey:UITextAttributeTextColor]; // --- 字体颜色
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"BJ.png"] forBarMetrics:UIBarMetricsDefault]; // — 背景色
D=>A 有根视图的话 (HOME)
[self.navigationController popToRootViewControllerAnimated:YES];
D=>C (每一个界面返回上一层)
[self.navigationController popViewControllerAnimated:YES];
返回到上一层,并且传递参数
CViewController *cvc = [CViewController alloc]init];
cvc.str = self.str;
[self.navigationController popToViewController:cvc animated:true];
返回到上一层后,上一页面显示后要接收参数,并刷新。注意此时应该在viewDidAppear中进行判断并接收传递的值
-(void)viewDidAppear:(BOOL)animated
{
//判断并接收返回的参数
}
NSArray *array = self.navigationController.viewControllers;
for (UIViewController *vc in array) {
if ([vc isKindOfClass:[BXXXViewController class]]) {
push VC;
}
或者知道每个界面的指针
[self.navigationController
popToViewController: [self.navigationController.viewControllers
objectAtIndex: ([self.navigationController.viewControllers count] -4)]
animated:YES];
在使用时,根据自己返回层的需要,只要改变一下“-4”这个数字就可以达到目的了
iOS viewController添加导航条以及返回跳转选择的更多相关文章
- iOS 状态栏和导航条配置
iOS 状态栏和导航条配置 一:隐藏: [self.navigationController setNavigationBarHidden:YES animated:YES]; [[UIApplica ...
- iOS学习——更改导航栏的返回按钮的标题与颜色
转载自:修改navigationController返回按钮颜色和文字 今天在做项目时遇到这个问题,试了很多方法都失败了.最后终于找到正确的方案了,在这里分享给大家. 引言 在iOS开发过程中,Nav ...
- 夺命雷公狗---DEDECMS----25dedecms导航条首页的跳转
我们的导航条首页一直没写跳转,现在我们看看dede自带模版的首页是怎么写的: 他也是封装了一个{dede:global.cfg_cmsurl/}/内置标签来实现的,那么我们来改下我们的head.htm ...
- iOS学习之导航条NavigationControl的一些属性设置
/** * 配置公共的属性,该属性作用于所有的导航条界面; */ - (void)configureConmmonPropety { //1.设置导航条的颜色 self.navigationContr ...
- iOS改变UINavigationBar导航条标题颜色和字体
转自:http://www.2cto.com/kf/201311/260409.html iOS 5 以后 UINavigationController 可以 改变UINavigationBar导航条 ...
- 模拟iOS系统原生导航条隐藏或显示动画
借UIView动画,使更改导航条的hidden属性这一过程动起来.悦德财富:https://yuedecaifu.com 代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
- iOS WKWebView添加进度条02
之前写了一个是关于webview添加进度条的,现在补一个WKWebView进度条. //添加一个全局属性 @property(nonatomic,strong)CALayer *progresslay ...
- iOS 如何设置导航的滑动返回手势, 和系统饿一样
iOS 7 滑动返回那些事儿 2014/05/17 Wei .entry-meta .entry-header 在智能机越来越普及,屏幕越做越大的当下,滑动返回手势已经成为了一个应用的标配功能,甚至可 ...
- 为ios app添加广告条
1.广告简介 2.实现步骤: 1>.添加 iAd.framework 框架 2,使用storyboard 运行结果: 2>添加 ADBannerView 视图,并设置代理方法 3>思 ...
随机推荐
- Strata 2014 上的 AzureCAT 粉笔会谈
本周,AzureCAT 团队非常高兴在 Strata 会议上首次集体亮相.对于那些对 AzureCAT 团队不太熟悉的人来说,我们是 Microsoft 云与企业部门一个核心的国际性团队,由大约 ...
- VS2010/MFC设置对话框控件的Tab顺序
设置对话框控件的Tab顺序 前面几节为大家演示了加法计算器程序完整的编写过程,本节主要讲对话框上控件的Tab顺序如何调整. 上一讲为“计算”按钮添加了消息处理函数后,加法计算器已经能够进行浮点数的加法 ...
- word中创建文本框
word中创建文本框 在插入中点击"文本框"选项卡,例如以下图所看到的: 手工加入自己想要的文本框格式,然后选择所创建的文本框,在工具栏处会发现多了一 ...
- eclipse hibernate插件在线安装
下面介绍下 关于在eclipse下如何在线安装插件 首先需要打开eclipse 点击 安装完成后,进入hibernate视图,在左侧窗口右键add configuration, 第一个name属性, ...
- 【转】Ubuntu常用软件合集
[转]Ubuntu常用软件合集 Ubuntu常用软件合集 我用的使Ubuntu-Kylin14.04,原因呢主要是觉得使本土化的,自带了日历.输入法.优客助手等易于上手的应用.也省的每次安装完原生的系 ...
- Android学习之DragEvent
关于DragEvent Google Android API中是这么说的 Represents an event that is sent out by the system at various t ...
- Oracle创建表、索引、主键、字段描述
-- 创建表 create table SX04_LBALANCE ( YEAR VARCHAR2(10) not null, PROGRAMNO VARCHAR2(40) not null, FDA ...
- Definitions
Definitions and ODR Definitions are declarations that fully define the entity introduced by the decl ...
- Android Studio does not point to a valid jvm
环境变量 JAVA_HOME的值,去掉后面的分号,一般情况下就可以启动
- Nginx 之六: Nginx十万并发优化
操作 操作 Nginx 之六: Nginx十万并发优化