About Windows and Views

关于窗口和视图

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中,你使用窗口和视图呈现应用程序里的内容到屏幕上。 窗口本身没有任何可视内容,只是给应用程序的视图提供了一个基本容器。视图定义了窗口的一部分,你能在视图上放置一些内容。 比如,你可能有一些视图,它们显示图片,文字,形状或一些它们的组合。你还可以使用视图来组织和管理别的视图。

At a Glance(概述)

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.

任何一个应用都至少有一个窗口和一个视图来显示它的内容。 UIKit 以及其它系统框架提供了预定义的各种视图来呈现你的内容。这些视图包括不仅简单的按钮和文本标签,还包括复杂的视图,比如表格视图,选择器视图,滚动视图等。如果预定义视图不能满足你的需求,你还可以自定义视图并由你自己管理绘图和事件处理。

Views Manage Your Application’s Visual Content

视图管理应用程序中的可视内容

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.

视图是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 框架有分别用来代表图像,文本以及其它类型内容的视图。

Windows Coordinate the Display of Your Views

窗口定位各种视图的显示

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 类的一个实例,它处理整个应用程序用户界面的外观。窗口跟视图(以及它们拥有的视图控制器)一起工作,来管理可见视图层次的交互及转换。大多数情况下,应用程序的窗口永远不会改变。 当窗口被创建了之后,它就一直保持不变,只有视图会根据变化显示不同的视图。 任何应用程序都至少有一个窗口,它在设备的主屏幕上显示应用程序的用户界面。 如果有外部显示被连接到设备,应用程序也能在屏幕上创建第二个窗口来呈现内容。

相关章节: “Windows”

Animations Provide the User with Visible Feedback for Interface Changes

动画在界面发生改变时给用户提供可见的反馈

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)层对象工作,你还可以执行很多其它动画。

相关章节: “Animations”

The Role of Interface Builder

界面生成器

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.

See Also(同时参考)

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.


 

View Programming Guide for iOS ---- iOS 视图编程指南(一)的更多相关文章

  1. Audio Queue Services Programming Guide(音频队列服务编程指南)

    Audio Queue Services 的苹果官方文档: https://developer.apple.com/library/ios/documentation/MusicAudio/Conce ...

  2. View Programming Guide for iOS ---- iOS 视图编程指南(四)---Views

    Views Because view objects are the main way your application interacts with the user, they have many ...

  3. 【IOS笔记】View Programming Guide for iOS -1

    原文:View Programming Guide for iOS View and Window Architecture Views and windows present your applic ...

  4. Collection View Programming Guide for iOS---(一)----About iOS Collection Views

    Next About iOS Collection Views 关于iOS Collection Views A collection view is a way to present an orde ...

  5. View Programming Guide for iOS_读书笔记[正在更新……]

    原文:View Programming Guide for iOS 1 Introduction 先熟悉一下基本概念. Window Windows do not have any visible c ...

  6. Collection View Programming Guide for iOS---(七)---Custom Layouts: A Worked Example

    Custom Layouts: A Worked Example Creating a custom collection view layout is simple with straightfor ...

  7. View Programming Guide for iOS ---- iOS 视图编程指南(二)---View and Window Architecture

    View and Window Architecture 视图和窗口架构 Views and windows present your application’s user interface and ...

  8. View Programming Guide for iOS ---- iOS 视图编程指南(五)---Animations

      Animations Animations provide fluid visual transitions between different states of your user inter ...

  9. View Programming Guide for iOS ---- iOS 视图编程指南(三)---Windows

    Windows Every iOS application needs at least one window—an instance of the UIWindow class—and some m ...

随机推荐

  1. iOS release版本去除NSLog打印信息

    因为NSLog的输出还是比较消耗系统资源的,而且输出的数据也可能会暴露出App里的保密数据,所以发布正式版时需要把这些输出全部屏蔽掉. 我们可以在发布版本前先把所有NSLog语句注释掉,等以后要调试时 ...

  2. Mysql数据库中CURRENT_TIMESTAMP和ON UPDATE CURRENT_TIMESTAMP区别

    如图所示,mysql数据库中,当字段类型为timestamp时,如果默认值取CURRENT_TIMESTAMP,则在insert一条记录时,end_time的值自动设置为系统当前时间,如果勾选了 ON ...

  3. UVA 1482 - Playing With Stones(SG打表规律)

    UVA 1482 - Playing With Stones 题目链接 题意:给定n堆石头,每次选一堆取至少一个.不超过一半的石子,最后不能取的输,问是否先手必胜 思路:数值非常大.无法直接递推sg函 ...

  4. CF 558B(Amr and The Large Array-计数)

    B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes input st ...

  5. The most widely used name server software: BIND

    https://www.isc.org/downloads/bind/ The most widely used name server software: BIND BIND is open sou ...

  6. VLFeat中SIFT特征点检测

    本代码使用VLFeat库中的函数对一幅图像进行了SIFT检测 需要事先配置好VLFeat和OpenCV,VLFeat的配置参考前一篇博文,OpenCV的配置网上一大堆,自己去百度 #include & ...

  7. 重构机房收费系统你要用的——异常处理和抛出异常(try catch finally)——(vb.net)

    你能保证你的程序不会出问题吗? 不能 当你的程序执行到某个地方发生了你不想要的结果.你是否想让它一错再错? 不想 你是否想让你的程序占着茅坑不拉屎? 不想 你是否想知道你的程序出错的原因? 想 个问题 ...

  8. 使用脚本删除ios工程中未使用图片

    使用脚本删除ios工程中未使用图片 最近在读唐巧大神的<iOS开发进阶>,学到了一个大招:使用脚本删除ios中未使用的图片(纸书上有点小问题,参考github上的issue:使用脚本删除i ...

  9. ARC机制之__strong具体解释

    ARC机制之__strong具体解释 __strong  解析: 默认情况下,一个指针都会使用 __strong 属性,表明这是一个强引用.这意味着,仅仅要引用存在,对象就不能被销毁.这是一种所期望的 ...

  10. Tomcat 安装与配置规范

    Tomcat 安装 演示版本:8.5.32 安装版 JDK推荐版本:jdk1.8 下载地址:https://tomcat.apache.org/download-80.cgi 安装教程 注意:tomc ...