导航控制器:UINavigationController
来源:互联网 发布:excel数据去除空格 编辑:程序博客网 时间:2024/04/28 12:18
/*
导航控制器:UINavigationController继承自UIViewController
视图控制器:UIViewController
UINavigationController:管理UIViewController
UIViewController:管理UIView
UINavigationController-》UIViewController-》 UIView
*/
RootViewController * root = [[[RootViewControlleralloc] init] autorelease];
UINavigationController * nav = [[[UINavigationControlleralloc] initWithRootViewController:root]autorelease];
NSLog(@"nav is %p",nav);
// root.view.backgroundColor = [UIColor grayColor];
//给视图控制器设置标题
root.title =@"Settings";
// 关联UINavigationController与UIViewController
/*
每一个导航控制器 都有一个栈 维护它的所有UIViewController
而且这个栈当中必须至少有一个视图控制器做为该栈的基栈
栈:先进后出
UINavigationController:UINavigation Bar(320*44) + CustomView(ctl.view) + UIToolbar(默认隐藏)
UINavigation Bar:backBarButtonItem(上一级ctl) + leftBarButtomItem + title(titleView) + rightBarButtonItem
*/
// 显示工具栏
// nav.toolbarHidden = NO;
// 让导航栏不透明
nav.navigationBar.translucent =NO;
// NSLog(@"%f",nav.navigationBar.frame.size.height);
self.window.rootViewController = nav;
return YES;
}
RootViewController.m
#import "ViewController1.h"
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view.
// UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
// label.backgroundColor = [UIColor redColor];
// [self.view addSubview:label];
// [label release];
NSLog(@"%p",self.navigationController);
UITapGestureRecognizer * tap = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(myTap)];
[self.viewaddGestureRecognizer:tap];
[taprelease];
}
- (void)myTap
{
//视图控制器入栈
ViewController1 * ctl1 = [[ViewController1alloc] init];
// ctl1.navigationController 为 nil
// ctl1.view.backgroundColor = [UIColor greenColor];
[self.navigationControllerpushViewController:ctl1 animated:YES];
NSLog(@"self %p",self.navigationController);
NSLog(@"ct1 %p",ctl1.navigationController);
// ctl1.navigationController 指向真实的物理空间
// [self presentViewController:ctl1 animated:YES completion:nil];
[ctl1release];
}
- (void)dealloc
{
NSLog(@"%@ dealloc",[selfclass]);
[superdealloc];
}
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view.
UITapGestureRecognizer * tap = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(click)];
[self.viewaddGestureRecognizer:tap];
[taprelease];
self.view.backgroundColor = [UIColorcolorWithRed:arc4random()%255/255.0green:arc4random()%255/255.0blue:arc4random()%255/255.0alpha:1.0];
//每次push的视图控制器都会保存在该结构中
NSLog(@"%@",self.navigationController.viewControllers);
UILabel * label = [[UILabelalloc] initWithFrame:CGRectMake(0,0, 100, 30)];
label.text = [NSStringstringWithFormat:@"%d层",self.navigationController.viewControllers.count];
label.center =CGPointMake(160,230);
label.textAlignment =NSTextAlignmentCenter;
label.backgroundColor = [UIColorclearColor];
[self.viewaddSubview:label];
[labelrelease];
}
- (void)click
{
ViewController1 * ctl1 = [[ViewController1alloc] init];
[self.navigationControllerpushViewController:ctl1 animated:YES];
// 不要写漏
[ctl1release];
}
- 导航视图控制器UINavigationController
- 导航控制器 ( UINavigationController )
- 导航控制器UINavigationController
- UINavigationController导航控制器详解
- UINavigationController导航控制器…
- UINavigationController导航控制器…
- UINavigationController导航控制器…
- UINavigationController 导航控制器
- 导航控制器UINavigationController
- 导航控制器:UINavigationController
- 自定义UINavigationController(导航控制器)
- swift UINavigationController 导航控制器
- UINavigationController 导航视图控制器
- UINavigationController 导航控制器
- UINavigationController 导航控制器
- UINavigationController导航控制器
- UI UINavigationController导航控制器
- UINavigationController---导航控制器
- HBase安装配置,使用独立zookeeper,shell测试
- android签名中的公钥和私钥
- 插入排序之希尔排序(Shell Sort)
- JPA与EJB3的关系
- Java和微软不得不说的故事
- 导航控制器:UINavigationController
- view仿射变换 缩放 旋转 平移
- IOS手机中图片的复制粘贴,剪切
- JTA和RESOURCE_LOCAL的区别
- asp.net mvc 3.0详细笔记__10__创建强类型视图
- 哈夫曼编码简介
- scanf的用法1
- android 编译源码错误
- 20、UIToolBar -OC+UI