UIWindow UIScreen UIViewController UIView之间的关系
2015-10-16 10:09
507 查看
转自: 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(视图)(视图)
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(视图)(视图)
相关文章推荐
- iOS 笔记八:Core Animation、Dynamic Animation、 UIDynamicBehavoir
- IOS学习动画一之 UIKit动画
- iOS UIView 添加点击事件
- UIDatePick,UIPick
- requireJS参数传递
- UIImage 和 NSString 之间的互转
- IOS之UITabBarController
- IOS does not contain bitcode. You must rebuild it with
- requirejs解决js跨域问题
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- 根据indexPath拿到UITableView的cell
- JS生成36为UUID
- requirejs学习笔记
- IOS-UITextField-全解
- UITableView小知识点总结
- POJ 2081 Recaman's Sequence(水的问题)
- iOS开发UI篇—ios应用数据存储方式(偏好设置)
- ValuesQuerySet对象 转换成json
- 复制ue中的十六进制内容
- 本地通知UILocalNotification