UIViewController施用 生命周期
UIViewController使用 生命周期
1 UIViewController 是个控制器 设置他需要设置他的view
2 UIViewController给我带来屏幕的旋转 他与UIView的选装不一样 他是旋转着个view 而后者只是单纯的选装屏幕
他还有很多功能 而后者是没有的
------Delegate方法中-----------------------------------
//RootViewControoler是写的一个集成UIViewController的文件
RootViewControoler *rv=[[RootViewControoler alloc]init];
[self.window addSubview rv.view]
---------------控制他的属性-----------------------
在RootViewControoler的初始方法中
self.view .frame=CGRectMake(0,0,320,480);
self.view.backgroundColor=[UIcolor redColor];
-----------------------他的生命周期-----------------------------------------------
这些方法在控制器都有 只是被注释啦
#pragma mark-view lifecycle //生命周期
-(void)loadView //创建时候 可以把view的创建写在这里面
{
UIView* vw=[[UIView* alloc]initWithFrame:CGRectMake(0,0,320,480)]
//[self.view addSubview:vw];如果你自己写一个init方法。就不能这么写啦 你使用这个方法 就相当于本自带view不能用啦
self.view=vw;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload //xib文件拖拽的东西 进行释放
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation //屏幕旋转
{
return YES;
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
============================================================
- (void)viewWillAppear:(BOOL)animated // Called when the view is about to made visible. Default does nothing
//将要加载出试图时
{
}
- (void)viewDidAppear:(BOOL)animated // Called when the view has been fully transitioned onto the screen. Default does nothing
{
//视图出现
}
- (void)viewWillDisappear:(BOOL)animated // Called when the view is dismissed, covered or otherwise hidden. Default does nothing
{
//视图将要消失
}
- (void)viewDidDisappear:(BOOL)animated // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
{
//视图已经消失
}
1 UIViewController 是个控制器 设置他需要设置他的view
2 UIViewController给我带来屏幕的旋转 他与UIView的选装不一样 他是旋转着个view 而后者只是单纯的选装屏幕
他还有很多功能 而后者是没有的
------Delegate方法中-----------------------------------
//RootViewControoler是写的一个集成UIViewController的文件
RootViewControoler *rv=[[RootViewControoler alloc]init];
[self.window addSubview rv.view]
---------------控制他的属性-----------------------
在RootViewControoler的初始方法中
self.view .frame=CGRectMake(0,0,320,480);
self.view.backgroundColor=[UIcolor redColor];
-----------------------他的生命周期-----------------------------------------------
这些方法在控制器都有 只是被注释啦
#pragma mark-view lifecycle //生命周期
-(void)loadView //创建时候 可以把view的创建写在这里面
{
UIView* vw=[[UIView* alloc]initWithFrame:CGRectMake(0,0,320,480)]
//[self.view addSubview:vw];如果你自己写一个init方法。就不能这么写啦 你使用这个方法 就相当于本自带view不能用啦
self.view=vw;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload //xib文件拖拽的东西 进行释放
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation //屏幕旋转
{
return YES;
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
============================================================
- (void)viewWillAppear:(BOOL)animated // Called when the view is about to made visible. Default does nothing
//将要加载出试图时
{
}
- (void)viewDidAppear:(BOOL)animated // Called when the view has been fully transitioned onto the screen. Default does nothing
{
//视图出现
}
- (void)viewWillDisappear:(BOOL)animated // Called when the view is dismissed, covered or otherwise hidden. Default does nothing
{
//视图将要消失
}
- (void)viewDidDisappear:(BOOL)animated // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
{
//视图已经消失
}