Screens, Windows, Views

Screens, Windows, Views

Figure 1-1  A window with its target screen and contentviews

 

There are three major objects at work here:

l A UIScreen object that identifies a physical screen connected tothe device.

l A UIWindow object that provides drawing support for the screen.

l A set of UIView objects to perform the drawing. Theseobjects are attached to the window and draw their contents when the window asksthem to.

 

 

Figure 1-2 shows how these classes (and related importantclasses) are defined in UIKit.

Figure 1-2  Classes in theview system

Views的特点:

l  一个视图代表一下用户交互元素,每个视图覆盖一个特定的区域。在这个区域中,视图显示和响应动作事件。UIView是从UIResponder继承的。

l  视图之间可以有父子层次关系。子视图在父视图内显示,这样父视图移动,子视图也会跟着移动

l  视图具有很强的模块化,与Controller和Model两边之间低耦合。当用户和视图所在区域交互,视图发送通知给Controller,但它并不知道它们响应在程序是做什么具体内容。

 

视图控制器管理视图

一个视图控制器管理一个视图,这个可能是有一堆子视图的根视图。

 

Figure 1-3  Aview controller attached to a window automatically adds its view as a subviewof the window

self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];

self.window.rootViewController = self.viewController;

[self.window makeKeyAndVisible];

窗口获取screen大小

给window设置根视图控制器,viewController会自动创建UIView视图。然后再显示。这是一个应用委托主要做的事情。

 

 

 

 

 

Figure1-5  View controller classes in UIKit

视图控制器分为内容视图控制器(content viewcontrollers)与容器视图控制器(container viewcontrollers)

内容视图控制器管理内容显示

容器视图控制器管理部署内容视图控制器

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值