关于窗口和视图html
In iOS, you use windows and views to present your application’s content on the screen. Windows do not have any visible content themselves but provide a basic container for your application’s views. Views define a portion of a window that you want to fill with some content. For example, you might have views that display images, text, shapes, or some combination thereof. You can also use views to organize and manage other views.ios
在iOS中,你使用窗口和视图呈现应用程序里的内容到屏幕上。 窗口自己没有任何可视内容,只是给应用程序的视图提供了一个基本容器。视图定义了窗口的一部分,你能在视图上放置一些内容。 好比,你可能有一些视图,它们显示图片,文字,形状或一些它们的组合。你还可使用视图来组织和管理别的视图。编程
Every application has at least one window and one view for presenting its content. UIKit and other system frameworks provide predefined views that you can use to present your content. These views range from simple buttons and text labels to more complex views such as table views, picker views, and scroll views. In places where the predefined views do not provide what you need, you can also define custom views and manage the drawing and event handling yourself.windows
任何一个应用都至少有一个窗口和一个视图来显示它的内容。 UIKit 以及其它系统框架提供了预约义的各类视图来呈现你的内容。这些视图包括不只简单的按钮和文本标签,还包括复杂的视图,好比表格视图,选择器视图,滚动视图等。若是预约义视图不能知足你的需求,你还能够自定义视图并由你本身管理绘图和事件处理。app
视图管理应用程序中的可视内容框架
A view is an instance of the UIView
class (or one of its subclasses) and manages a rectangular area in your application window. Views are responsible for drawing content, handling multitouch events, and managing the layout of any subviews. Drawing involves using graphics technologies such as Core Graphics, OpenGL ES, or UIKit to draw shapes, images, and text inside a view’s rectangular area. A view responds to touch events in its rectangular area either by using gesture recognizers or by handling touch events directly. In the view hierarchy, parent views are responsible for positioning and sizing their child views and can do so dynamically. This ability to modify child views dynamically lets your views adjust to changing conditions, such as interface rotations and animations.ide
视图是UIView类(或是它的子类)的一个实例,它管理应用程序窗口中一个矩形区域。 视图负责绘制内容,处理多点触摸事件,以及管理任何子视图的布局。绘图涉及使用各类图像技术,好比 Core Graphics, OpenGL ES, 或UIKit ,来绘制形状,图片,以及在视图矩形区域内的文本。 视图在它的矩形区域内对触摸事件作出响应,经过手势辨认或是直接处理触摸事件。在视图层次中, 父视图负责给子视图定位和定尺寸,并能动态的完成这些工做。 该动态修改子视图的能力能让视图适应各类变化条件,好比界面转动和动画等。布局
You can think of views as building blocks that you use to construct your user interface. Rather than use one view to present all of your content, you often use several views to build a view hierarchy. Each view in the hierarchy presents a particular portion of your user interface and is generally optimized for a specific type of content. For example, UIKit has views specifically for presenting images, text and other types of content.学习
你能够把视图想象成构建块,你能够用它们来构建你本身的接口。你一般会使用几个视图来创建一个视图层次,而不是把全部的内容都放置在一个视图里。 层次里的每一个视图都表明用户界面的一部分, 并且通常是一种特定类型的内容。 好比,UIKit 框架有分别用来表明图像,文本以及其它类型内容的视图。flex
窗口定位各类视图的显示
A window is an instance of the UIWindow
class and handles the overall presentation of your application’s user interface. Windows work with views (and their owning view controllers) to manage interactions with, and changes to, the visible view hierarchy. For the most part, your application’s window never changes. After the window is created, it stays the same and only the views displayed by it change. Every application has at least one window that displays the application’s user interface on a device’s main screen. If an external display is connected to the device, applications can create a second window to present content on that screen as well.
窗口是UIWindow 类的一个实例,它处理整个应用程序用户界面的外观。窗口跟视图(以及它们拥有的视图控制器)一块儿工做,来管理可见视图层次的交互及转换。大多数状况下,应用程序的窗口永远不会改变。 当窗口被建立了以后,它就一直保持不变,只有视图会根据变化显示不一样的视图。 任何应用程序都至少有一个窗口,它在设备的主屏幕上显示应用程序的用户界面。 若是有外部显示被链接到设备,应用程序也能在屏幕上建立第二个窗口来呈现内容。
动画在界面发生改变时给用户提供可见的反馈
Animations provide users with visible feedback about changes to your view hierarchy. The system defines standard animations for presenting modal views and transitioning between different groups of views. However, many attributes of a view can also be animated directly. For example, through animation you can change the transparency of a view, its position on the screen, its size, its background color, or other attributes. And if you work directly with the view’s underlying Core Animation layer object, you can perform many other animations as well.
动画给用户提供可见的反馈,这些反馈关于视图层次上的各类改变。系统定义了标准动画来呈现模型视图以及不一样视图组之间的转换。 然而, 不少视图的属性也能直接被动画。好比,经过动画你能够改变视图的透明度, 它在屏幕上的位置,尺寸,背景颜色或其它属性。 并且若是你直接用视图的相关核心动画(Core Animation)层对象工做,你还能够执行不少其它动画。
界面生成器
Interface Builder is an application that you use to graphically construct and configure your application’s windows and views. Using Interface Builder, you assemble your views and place them in a nib file, which is a resource file that stores a freeze-dried version of your views and other objects. When you load a nib file at runtime, the objects inside it are reconstituted into actual objects that your code can then manipulate programmatically.
界面生成器是用来图形化构造和配置应用程序窗口和视图的应用。 使用界面生成器,你组合各类视图,并把它们放在一个nib文件中。nib 文件是一个资源文件,它用来存储视图的冻干(freeze-dried)版本以及其它对象。当你在运行时载入一个nib文件时,文件里的全部对象被改组为实际的对象,而后你的代码能对这些对象进行编程操做。
Interface Builder greatly simplifies the work you have to do in creating your application’s user interface. Because support for Interface Builder and nib files is incorporated throughout iOS, little effort is required to incorporate nib files into your application’s design.
界面生成器大大简化了建立应用程序用户界面时你不得不作的工做。 由于整个iOS都支持界面生成器和nib文件,你只须要一点努力就能够把nib文件组合到应用程序设计中去。
For more information about how to use Interface Builder, see Interface Builder User Guide. For information about how view controllers manage the nib files containing their views, see “Custom View Controllers” in View Controller Programming Guide for iOS.
要想了解更多有关使用界面生成器的信息,查看《Interface Builder User Guide--界面生成器使用指南》。有关视图控制器如何管理包含各类视图的nib文件的详细信息,查看“Custom View Controllers” in View Controller Programming Guide for iOS.
Because views are very sophisticated and flexible objects, it would be impossible to cover all of their behaviors in one document. However, other documents are available to help you learn about other aspects of managing views and your user interface as a whole.
由于视图是一些很是复杂和灵活的对象,不可能在一个文档里所有讲述它们。 然而,其它文档能帮助你全面学习有关管理视图的其它方面,以及整个用户界面。
View controllers are an important part of managing your application’s views. A view controller presides over all of the views in a single view hierarchy and facilitates the presentation of those views on the screen. For more information about view controllers and the role they play, see View Controller Programming Guide for iOS.
视图控制器是管理应用程序视图的重要一部分。 一个视图控制器管理着一个视图层次里的全部视图,并让这些视图的外观显示在屏幕上。 关于更多视图控制器的信息以及它们所扮演的角色,请查看 View Controller Programming Guide for iOS.
Views are the key recipients of gesture and touch events in your application. For more information about using gesture recognizers and handling touch events directly, see Event Handling Guide for iOS.
视图是应用程序中手势和触摸事件的主要接收者。更多关于使用手势辨认器和直接处理触摸事件的信息,请看Event Handling Guide for iOS.
Custom views must use the available drawing technologies to render their content. For information about using these technologies to draw within your views, see Drawing and Printing Guide for iOS.
自定义视图必须使用可行的绘制技术,用来呈现它们的内容。 关于用来在视图里绘制的这些技术,请看Drawing and Printing Guide for iOS.
In places where the standard view animations are not sufficient, you can use Core Animation. For information about implementing animations using Core Animation, see Core Animation Programming Guide.
当标准视图动画没有效果时,你可使用内核动画。 关于用内核动画实现动画的信息,请看 Core Animation Programming Guide.