UIScreen(屏幕)、UIWindow(画框…

来源:互联网 发布:mac pro 涂层脱落 编辑:程序博客网 时间:2024/05/01 23:14
//didFinishLaunchingWithOptions方法:顾名思义。在app开始运行时会调用里面的方法。
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    //返回的是带有状态栏的矩形
    self.window= [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];
   
    CGRectbound = [[UIScreenmainScreen]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-0323:21:45.716 DinkMixer[599:c07]boundwith:320.000000    boundheight:480.000000
    //2012-08-0323:21:45.719 DinkMixer[599:c07]boundx:0.000000    boundy:0.000000


    CGRectappBound = [[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-0323: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.windowmakeKeyAndVisible];//这行代码会让包含了视图控制器视图的Window窗口显示在屏幕上。
    returnYES;
}
0 0