// 属性赋值的方法1:
/*
UIWindow *win = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
win.backgroundColor = [UIColor whiteColor];
self.window = win;
[win release];
[self.window makeKeyAndVisible];
*/
// method(方法) 2:
CGRect screen = CGRectMake(0, 0, 320, 568);
//属性赋值 retain一次
self.window = [[[UIWindow alloc] initWithFrame:screen] autorelease];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
// 创建一个视图控制器
HomeViewController *homeViewController = [[HomeViewController alloc]init];
// 设置根视图控制器
self.window.rootViewController = homeViewController;
[homeViewController release];
非ARC环境下,属性赋值注意的类存问题,在dealloc方法里面释放属性
视图控制器控制一个视图,视图大小始终被系统自动优化为全屏
可以在
HomeViewController里面的loadView里面添加子视图
-(void)loadView加载视图时执行(一般用来添加视图)
- (void)viewDidLoad视图加载完执行(一般用来添加数据)
- (void)didReceiveMemoryWarning 接收到内存警告的时候执行
还有旋转(横竖屏是执行的方法)