IOS 集合视图指南1:介绍

About iOS Collection Views(关于IOS集合视图)

A collection view is a way to present an ordered set of data items using a flexible and changeable layout. The most common use for collection views is to present items in a grid-like arrangement, but collection views in iOS are capable of more than just rows and columns. With collection views, the precise layout of visual elements is definable through subclassing and can be changed dynamically, so you can implement grids, stacks, circular layouts, dynamically changing layouts, or any type of arrangement you can imagine.

Collection views keep a strict separation between the data being presented and the visual elements used to present that data. In most cases, your app is solely responsible for managing the data. Your app also provides the view objects used to present that data. After that, the collection view takes your views and does all the work of positioning them onscreen. It does this work in conjunction with a layout object, which specifies the placement and visual attributes for your views and that can be subclassed to fit your app’s exact needs. Thus, you provide the data, the layout object provides the placement information, and the collection view merges the two pieces together to achieve the final appearance.

集合视图是一种通过灵活多变的布局展现有序数据项的方法。通常集合视图把数据展示成网状,但是IOS中的集合视图能胜任的远远不止行和列。集合视图可以通过子类化来实现元素的精确定位和动态更改,于是你可以实现网站,栈形,循环以及任何你能想到的各种布局。

集合视图保证了界面和数据的严格分离。在大部分情况下,你的应用只需要负责管理数据。然后,集合视图会完成你所有的界面布局任务。集合视图和布局对象一起完成这些工作,布局对象指定了你的视图的位置和市局属性,你可以通过子类化布局对象来实现你的应用的切实需求。于是呢,你提供的数据信息,布局对象提供的位置信息,由集合视图综合起来实现最终的展示效果。

At a Glance(概览)

The standard iOS collection view classes provide all of the behavior you need to implement simple grids. You can also extend the standard classes to support custom layouts and specific interactions with those layouts.

标准的IOS集合视图类提供了你实现一个简单网格的所有行为。当然你也可以拓展标准类以支持自定义布局和那些相互作用的布局。

A Collection View Manages the Visual Presentation of Data-Driven Views

A collection view facilitates the presentation of data-driven views provided by your app. The collection view’s only concern is taking your views and laying them out in a specific way. The collection view is all about the presentation and arrangement of your views and not about their content. Understanding the interactions between the collection view, its data source, the layout object, and your custom objects is crucial for using collection views in your app, particularly in smart and efficient ways.

Relevant chapters:Collection View Basics,Designing Your Data Source and Delegate

集合视图控制视觉展现(数据—驱动—视图)

集合视图便于展示由应用程序提供的数据驱动的视图。集合视图只关心获取你的视图并且把他们按照特定的方式布局。集合视图只关心如何展示和安排你的视图并不关系视图中的内容。理解视图之间的相互关系,,数据源,布局对象,和你的自定义对象是在你的应用里面使用的集合视图的关键,特别是智能和有效方法。

相关章节:集合视图基础,设计你的数据源和代理

The Flow Layout Supports Grids and Other Line-Oriented Presentations

A flow layout object is a concrete layout object provided by UIKit. You typically use the flow layout object to implement grids—that is, rows and columns of items—but the flow layout supports any type of linear flow. Because it is not just for grids, you can use the flow layout to create interesting and flexible arrangements of your content both with and without subclassing. The flow layout supports items of different sizes, variable spacing of items, custom headers and footers, and custom margins without subclassing. And subclassing allows you to tweak the behavior of the flow layout class even further.

支持网格和其他线性展示的流动布局

流动布局对象是UIKit框架提供的一个具体的布局对象。通常情况下,你可以使用流动布局对象来实现网格(由行列元素组成),但是流动布局对象支持任何类型的流线型布局。因为流动布局不仅仅支持网络布局,不管你使用不使用子类化,你都可以使用流动布局创建流畅有趣的内容排布。在没有子类化的情况下流动布局可以支持,不同尺寸的元素,他们之间变化的距离,自定义页眉页脚,和自定义的边界。通过子类化你可以把流动布局类调整的更加强大。

Relevant chapter:Using the Flow Layout

相关章节:使用流动布局Gesture Recognizers Can Be Used for Cell and Layout Manipulations

Like all views, you can attach gesture recognizers to a collection view to manipulate the content of that view. Because a collection view involves the collaboration of multiple views, it helps to understand some basic techniques for incorporating gesture recognizers into your collection views. You can use gesture recognizers to tweak layout attributes or to manipulate items in a collection view.

手势操作可以使用在单元格和布局操作中就像所有视图一样 ,你可以给集合视图添加手势识别来操控诸多内容视图。因为集合视图牵涉了多视图的协作,这会帮助你理解集合视图之中多个视图协作的基本技术。你可以使用手势识别来调整集合视图中的布局属性和操作视图中的元素。

便觉不过如此。也许我们只是想让自己的心去旅行,

IOS 集合视图指南1:介绍

相关文章:

你感兴趣的文章:

标签云: