初学iOS,翻的不好还请帮忙指正,欢迎大家一起讨论学习!
Introduction
引言
About Windows and Views
一、关于窗口和视图
IniOS, you use windows and views to present your application’s content on thescreen. Windows do not have any visible content themselves but provide a basic containerfor your application’s views.Views definea portion ofawindow that you want to fill with some content.For example, you mighthave views that display images, text, shapes, or some combination thereof. Youcan 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 notprovide what you need, you can also define custom views and manage the drawingand event handling yourself.
每个应用至少有一个窗口和一个视图用来呈现它的内容。UIKit和其他系统框架提供给你能够用来呈现你内容的预定义视图。这些视图包含从单个按钮和文本标签到更复杂的视图,如table views,picker views和scroll views。在某些地方预定义视图无法提供你想要的,你自己也能够自定义视图,管理绘图和事件处理。
Views Manage Your Application’s Visual Content
三、视图管理你应用的可视内容
A view is an instance of theUIView class (or one of its subclasses) and manages arectangular area in your application window. Views are responsible for drawingcontent, handling multitouch events, and managing the layout of any subviews.Drawing involves using graphicstechnologies such as Core Graphics, OpenGL ES, or UIKit to draw shapes,images, and text inside a view’s rectangular area. A view responds to touchevents in its rectangular area either by using gesture recognizers or byhandling touch events directly. In the view hierarchy,parent views are responsible for positioning and sizing their child viewsand 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类(或它的子类)的一个实例,它管理着你的应用窗口中的一个矩形区域。视图负责绘制内容,处理多点触控事件和管理任何subviews的布局。绘图包含使用图像技术如Core Graphics, OpenGL ES,或者UIKit来绘制形状,图像和视图的矩形区域内部的文本。视图通过使用手势识别或是直接处理触摸事件来响应在它矩形区域的触摸事件。在视图的层级中,父视图负责对它们的子视图定位和定尺寸并能够动态的进行处理。动态地修改子视图的能力让你的视图能够适应不断变化的环境,例如界面旋转和动画。
Youcan think of views as building blocks that you use to construct your userinterface. Rather than use one view to present all of your content, you oftenuse several views to build a view hierarchy. Each view in the hierarchypresents a particular portion of your user interfaceand is generally optimized for a specific type of content. For example,UIKit has views specifically for presenting images, text and other types ofcontent.
你可以把视图想象为构建块,你使用它来组成你的用户界面。你常常会使用多个视图来构建一个视图层级,而不是使用一个视图来呈现你所有的内容。在层级中的每个视图呈现了你的用户界面的某一部分,而且对于特定类型的内容通常是最优的。例如,UIKit有特定地为呈现图像,文本和其他类型内容的视图。
Relevant Chapters:View
and Window Architecture,Views
Windows Coordinate the Display of Your Views
四、窗口协调你的视图的显示
Awindow is an instance of the UIWindow class and handles the overallpresentation of your application’s user interface. Windows work with views (andtheir owning view controllers) to manage interactions with, and changes to, thevisible view hierarchy. For the most part, your application’s window neverchanges. After the window is created, it stays the same andonly the views displayedby it change.Every application has at least one window that displays the application’s userinterface on a device’s main screen. If an external display is connected to thedevice, applications can create a second window to present content on thatscreen as well.
窗口是UIWindow类的实例,它处理你整个应用的用户界面的显示。窗口与视图(和他们拥有的视图控制器)协作管理可见视图层级的交互和变化。就绝大部分而言,你的应用的窗口绝不会改变。当window创建以后,它会保持不变仅仅视图通过它来改变显示。每个应用至少有一个窗口用来在设备的主屏幕上显示应用的用户界面。假如一个外部的显示器连接到这个设备,应用程序也能够创建第二个窗口在那个屏幕上显示内容。
Relevant Chapters:Windows
Animations Provide the User with Visible Feedback forInterface Changes
五、动画为界面的变化提供给用户可视的反馈
Animationsprovide users with visible feedback about changes to your view hierarchy. Thesystem defines standard animations for presenting modal views and transitioningbetween different groups of views. However, many attributes of a view can alsobe animated directly. For example, through animation you can change thetransparency of a view, its position on the screen, its size, its backgroundcolor, or other attributes. And if you work directly with the view’s underlyingCore Animation layer object, you can perform many other animations as well.
对于你视图层级的改变,动画提供给用户可视的反馈。系统定义了标准动画来呈现模型视图(modal views)和不同组视图之间的过渡显示。然而,视图的许多属性也能直接动画显示。例如,通过动画你能够改变视图的透明度,在屏幕的位置,尺寸,背景颜色或其他属性。而且如果你直接地使视图的底层(underlying)Core Animation layer对象工作,你也能执行许多其他的动画。
Relevant Chapters:Animations
The Role of Interface Builder
六、界面生成器的作用
InterfaceBuilder is an application that you use to graphically construct and configureyour application’s windows and views. Using Interface Builder, you assembleyour views and place them in a nib file, which is a resource file that stores afreeze-dried version of your views and other objects. When you load a nib fileat runtime, the objects inside it are reconstituted into actual objects thatyour code can thenmanipulate programmatically.
界面生成器是一个应用程序,你使用它来图形化地构造和配置你应用的窗口和视图。使用界面生成器,你组合你的views然后把它们放置在一个nib文件里,nib文件是一个存储你视图的一个冻干(freeze-dried)版本以及其他对象的资源文件。当你在运行时加载一个nib文件,在它里面的对象被重新生成为你的代码能够操作编程的实际对象。
InterfaceBuilder greatly simplifies the work you have to do in creating yourapplication’s user interface. Because support for Interface Builder and nib filesis incorporated throughout iOS, little effort is required to incorporate nibfiles into your application’s design.
界面生成器简化了你在创建你应用的用户界面的工作。因为对界面生成器和nib文件的支持被集成到整个iOS里,在你应用的设计中集成nib文件仅需要很少的工作
Formore information about how to use Interface Builder, see Interface Builder UserGuide. For information about how view controllers manage the nib filescontaining their views, see “Creating Custom Content View Controllers” inView Controller Programming Guide for iOS.
为了解更多关于怎样使用界面生成器的信息,请查看Interface Builder User Guide。有关视图控制器怎样管理nib文件和他们的视图,在View Controller Programming Guide for iOS中查看“Creating Custom Content View Controllers”
See Also
七、同时参考
Becauseviews are very sophisticated and flexible objects, it would be impossible tocover all of their behaviors in one document. However, other documents areavailable to help you learn about other aspects of managing views and your userinterface as a whole.
因为视图是非常复杂和灵活的对象,不可能在一个文档中覆盖它的所有特性。然而,其他文档作为一个整体可以帮助您了解管理视图和用户界面的其他方面。
lView controllers are an important part of managing yourapplication’s views. A view controller presides over all of the views in asingle view hierarchy and facilitates the presentation of those views on thescreen. For more information about view controllers and the role they play, seeView Controller Programming Guide for iOS.
视图控制器是管理你应用views的重要部分。一个视图控制器管理着一个视图层级里的所有视图,而且方便这些视图显示在屏幕上。更多关于视图控制器和他们运行的规则的信息,请查看View Controller Programming Guide for iOS.
lViews are the key recipients of gesture and touch events in yourapplication. For more information about using gesture recognizers and handlingtouch events directly, seeEvent Handling Guide for iOS.
在你的应用程序中视图是手势和触摸事件的关键接收者。关于更多使用手势识别和直接处理触摸事件的信息,请查看Event Handling Guide for iOS.
lCustom views must use the available drawing technologies to rendertheir content. For information about using these technologies to draw withinyour views, seeDrawing and Printing Guide for iOS.
自定义视图必须使用有效的绘制技术用来呈现他们的内容。关于在你的视图内使用这些技术进行绘制的信息,请查看Drawing and Printing Guide for iOS。
lIn places where the standard view animations are not sufficient, you
can use Core Animation. For information about implementing animations using
Core Animation, seeCore Animation Programming Guide.
某些地方标准的视图动画是不足的,你可以使用Core Animation。关于使用Core Animation执行动画的信息,请参考Core Animation Programming Guide。
网友评论