轉自:
http://blog.csdn.net/heng615975867/article/details/39053695
UIScreen(屏幕,一直存在)
---》UIWindow(畫框)
---》UIViewController(視圖控制器)
---》UIView(視圖)
//didFinishLaunchingWithOptions 方法:顧名思義。在app開始運行時會調用裏面的方法。
-(BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//返回的是帶有狀態欄的矩形
self.window = [[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
//返回的是帶有狀態欄的Rect
CGRect bound = [[UIScreen mainScreen]bounds];
NSLog(@"boundwith:%f boundheight:%f",bound.size.width,bound.size.height);
NSLog(@"boundx:%f boundy:%f",bound.origin.x,bound.origin.y);
//2012-08-0323:21:45.716 DinkMixer[599:c07]boundwith:320.000000 boundheight:480.000000
//2012-08-03 23:21:45.719 DinkMixer[599:c07] boundx:0.000000 boundy:0.000000
CGRect appBound = [[UIScreenmainScreen]applicationFrame]; //返回的是不帶有狀態欄的Rect
NSLog(@"appBoundwith:%f boundheight:%f",appBound.size.width,appBound.size.height);
NSLog(@"appBoundx:%f boundy:%f",appBound.origin.x,appBound.origin.y);
//2012-08-0323:21:45.720 DinkMixer[599:c07]appBoundwith:320.000000 boundheight:460.000000
//2012-08-03 23:21:45.720 DinkMixer[599:c07]appBoundx:0.000000 boundy:20.000000
//很明顯狀態欄佔用了空間20像素
//根據nib文件的名稱來創建一個視圖控制器
MasterViewController*masterViewController = [[[MasterViewController alloc]initWithNibName:@"MasterViewController" bundle:nil] autorelease];
//創建一個導航控制器,並指定該導航控制器的根視圖控制器爲上面建立的masterViewController
self.navigationController= [[[UINavigationController alloc]initWithRootViewController:masterViewController] autorelease];
//窗體(window)有一個根視圖控制器——這個視圖控制器負責配置當窗體顯示時最先顯示的視圖。要讓你的視圖控制器的內容顯示在窗體中,需要去設置窗體的根視圖控制器爲你的視圖控制器。
self.window.rootViewController = self.navigationController;
//這行代碼會讓包含了視圖控制器視圖的Window窗口顯示在屏幕上。
[self.window makeKeyAndVisible];
return YES;
}
---》UIView(視圖)(視圖)