//didFinishLaunchingWithOptions 方法:顧名思義。在app開始運行時會調用裏面的方法。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//返回的是帶有狀態欄的矩形
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
CGRect bound = [[UIScreen mainScreen]bounds];
//返回的是帶有狀態欄的Rect
NSLog(@"boundwith:%f boundheight:%f",bound.size.width,bound.size.height);
NSLog(@"boundx:%f boundy:%f",bound.origin.x,bound.origin.y);
//2012-08-03 23: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 = [[UIScreen mainScreen]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-03 23: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像素
MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
//根據nib文件的名稱來建立一個視圖控制器
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
//建立一個導航控制器,並指定該導航控制器的根視圖控制器爲上面創建的masterViewController
self.window.rootViewController = self.navigationController;//窗體(window)有一個根視圖控制器——這個視圖控制器負責配置當窗體顯示時最早顯示的視圖。要讓你的視圖控制器的內容顯示在窗體中,須要去設置窗體的根視圖控制器爲你的視圖控制器。
[self.window makeKeyAndVisible];
//這行代碼會讓包含了視圖控制器視圖的Window窗口顯示在屏幕上。
return YES;
}
轉自:http://blog.sina.com.cn/s/blog_74f70b7901017f9t.html