UIViewController加载过程
UIViewController是视图和数据的桥梁,UIViewController是所有controller的基类,ios内置了很多试图控制器,如导航控制器,tableViewController等。
视图控制本身包含一个视图,是view。UIScreen是连接物理屏幕的标示,UIWindow是为UIScreen提供了一个画布。
加载过程分为以下几步:
-(void)loadView{ NSLog(@"loadView");// UIView *view=[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];// view.backgroundColor=[UIColor greenColor];// self.view=view;// [view release]; //添加子视图}- (void)viewDidLoad{ [super viewDidLoad]; UIView *view=[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; view.backgroundColor=[UIColor greenColor]; [self.view addSubview:view]; [view release]; NSLog(@"view Did Load"); //注意上面的操作会判断view是否为空,如果view为空,就会调用loadview方法// Do any additional setup after loading the view.}
第四、- (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