UIWindow介绍
来源:互联网 发布:ios 分页加载数据 编辑:程序博客网 时间:2024/04/30 06:02
UIWindow是一种特殊的UIView,通常在一个app中只会有一个UIWindow,可以手动创建多个UIWindow,添加到程序中。
UIWindow在程序中起3个作用:
1、作为容器,包含app所要显示的所有视图
2、传递触摸消息到程序中view和其他对象
3、与UIViewController协同工作,方便完成设备方向旋转的支持
一个iOS程序之所以能显示到屏幕上,完全是因为它有UIWindow。也就说,没有UIWindow,就看不见任何UI界面:
配置窗口:
1.UIWindow在显示的时候会根据UIWindowLevel进行排序的,即Level高的将排在所有Level比他低的层级的前面:
@property(nonatomic) UIWindowLevel windowLevelUIWindowLevel的定义:
const UIWindowLevel UIWindowLevelNormal ;const UIWindowLevel UIWindowLevelAlert ;const UIWindowLevel UIWindowLevelStatusBar ;typedef CGFloat UIWindowLevel;系统中定义了三个window层级,其中每一个层级又可以分好多子层级(从UIWindow的头文件中可以看到成员变量CGFloat _windowSublevel;),不过系统并没有把则个属性开出来。UIWindow的默认级别是UIWindowLevelNormal,iOS他们级别的高低顺序从小到大为Normal < StatusBar < Alert。
注意:这说明当Level层级相同的时候,只有第一个设置为KeyWindow的显示出来,后面同级的再设置KeyWindow也不会显示。UIWindow在显示的时候是不管KeyWindow是谁,都是Level优先的,即Level最高的始终显示在最前面。
通常我们的程序的界面都是处于Normal这个级别上的,系统顶部的状态栏应该是处于StatusBar级别,UIActionSheet和UIAlertView这些通常都是用来中断正常流程,提醒用户等操作,因此位于Alert级别。
根据window显示级别优先的原则,级别高的会显示在上面,级别低的在下面,我们程序正常显示的view位于最底层。
2.当前屏幕显示的窗口:
@property(nonatomic, retain) UIScreen *screen默认情况下,所有的窗口都由主屏幕创建。如果有额外的屏幕连接到设备,指定一个不同的对象使新窗口显示在屏幕上。
3.窗口的根视图控制器:
@property(nonatomic, retain) UIViewController *rootViewController
窗口键:
4.唯一一个可以接受响应的Window:
@property(nonatomic, readonly, getter=isKeyWindow) BOOL keyWindow如果当前UIWindow的keyWindow设置为YES,便成为唯一一个可以接受响应的Window,在一个应用程序中只有唯一一个keyWindow。
5.设置主window并显示出来:
- (void)makeKeyAndVisible
6.调用窗口,使之变为关键窗口:
- (void)becomeKeyWindow这个方法将接收第一个响应,那如果它响应对象,则发送uiwindowdidbecomekeynotification消息到通知中心。
7.使之成为主窗口:
- (void)makeKeyWindow
8.调用窗口,使之取消关键窗口:
- (void)resignKeyWindow
转换坐标:
9.转化当前窗口一个坐标相对另外一个窗口的坐标:
- (CGPoint)convertPoint:(CGPoint)point toWindow:(UIWindow *)window
10.转化另外窗口一个坐标相对于当前窗口的坐标:
- (CGPoint)convertPoint:(CGPoint)point fromWindow:(UIWindow *)window
11.转化当前窗口一个矩形坐标相对另外一个窗口的坐标:
- (CGRect)convertRect:(CGRect)rect toWindow:(UIWindow *)window
12.转化另外窗口一个矩形坐标相对于当前窗口的坐标:
- (CGRect)convertRect:(CGRect)rect fromWindow:(UIWindow *)window
发送事件:
13.发送事件:
- (void)sendEvent:(UIEvent *)event
常数:
14.
NSString *const UIKeyboardFrameBeginUserInfoKey ;NSString *const UIKeyboardFrameEndUserInfoKey ;NSString *const UIKeyboardAnimationDurationUserInfoKey ;NSString *const UIKeyboardAnimationCurveUserInfoKey ; // Deprecated in iOS 3.2 and later.NSString *const UIKeyboardCenterBeginUserInfoKey ;NSString *const UIKeyboardCenterEndUserInfoKey ;NSString *const UIKeyboardBoundsUserInfoKey;
通知:
UIWindowDidBecomeVisibleNotification
UIWindowDidBecomeHiddenNotification
UIWindowDidBecomeKeyNotification
UIWindowDidResignKeyNotification
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
UIKeyboardWillChangeFrameNotification
UIKeyboardDidChangeFrameNotification
- UIWindow介绍
- UIWindow介绍
- UIWindow介绍
- UIWindow简单介绍
- UIWindow使用介绍
- UIWindow简单介绍
- UIWindow简单介绍
- UIWindow简单介绍
- UIWindow简单介绍
- UIWindow简单介绍
- iOS UIWindow基本介绍
- UIWindow简单介绍
- UIWindow的介绍和使用
- UIWindow 史上最详细的介绍
- Ui 一一 UIWindow基本介绍
- UIWindow
- UIWindow
- UIWindow
- 第8章 子查询
- Java正则表达式
- 超简单的短网址php实现
- mybatis源码总结--快速入门(1)
- 创建Android插件 Building Plugins for Android
- UIWindow介绍
- 【转载】char* string CString比较总结
- Encode和Decode作用,意义和用法
- MFC访问数据库
- cigarettes(南阳oj94)
- Problem 017 ——UVa 1368 -DNA Consensus String
- Problem 018 ——UVa 10340 - All in All
- 沮仆妒蛹诿帽投妒米瞪缺坑缺妒韶
- 笆督食投仄柑诿瞪刨琳秆投迸街雇