---
title: "IOS"
author: "wenqxin"
date: "2013-07-16T22:41:05Z"
tags: []
categories: ["移动开发"]
slug: "ios"
draft: false
lastmod: "2013-07-16T22:41:42Z"
id: 1908107
url: "https://sectioncc.iteye.com/blog/1908107"
---

-----------------------UIViewController生命周期----------------------------------------------- 

 

// ＋1 使用Nib文件名，初始化

\- (id)initWithNibName:(NSString \*)nibNameOrNil bundle:(NSBundle \*)nibBundleOrNil

**补充： 这个阶段界面传递的参数还未加载**

 

//＋2 创建时候 可以把view的创建写在这里面 

 -(void)loadView 

 

//+3  view已经加载   
\- (void)viewDidLoad   
**补充： 这个阶段界面传递的参数可以获取**

       **界面高度和宽度 还是按照标准的320\*480计算的**

        **同时：可以用** self.view.frame.size.height 获取高度

 

//＋4将要加载出视图时 

\- (void)viewWillAppear:(BOOL)animated // Called when the view is about to made visible. Default    
补充说明：

     这个阶段界面按照实际手机的分辨率，及控件的设置的扩展属性进行高度和宽度的计算。

      

//＋5 视图可见  
\- (void)viewDidAppear:(BOOL)animated    
 

//00 视图翻转  
\- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation //屏幕旋转 

//－5 视图将要消失  
\- (void)viewWillDisappear:(BOOL)animated // Called when the view is dismissed, covered or otherwise hidden. Default does nothing 

 

//-4视图已经消失   
\- (void)viewDidDisappear:(BOOL)animated // Called after the view was dismissed, covered or otherwise hidden. Default does nothing 

//-3视图卸载

\- (void)viewDidUnload