码迷,mamicode.com
首页 > 移动开发 > 详细

IOS 集合视图指南1:介绍

时间:2015-03-05 17:10:46      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:uicollection   官方文档   

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.

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

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


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


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.

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


Relevant chapter: Incorporating Gesture Support

相关章节:结合手势支持

Custom Layouts Let You Go Beyond Grids(自定义布局让你超越网格布局)

You can subclass the basic layout object to implement custom layouts for your app. Even though designing a custom layout does not typically require a large amount of code, the more you understand how layouts work, the better you can design your layout objects to be efficient. The guide’s final chapter focuses on an example project with a full implementation of a custom layout.

你可以子类化基础布局对象来实现让你的应用自定义布局。尽管通常情况下自定义布局并不需要大量代码,但是你越理解布局是怎样工作的,你设计的布局对象就越有效。在指南的最后一章节,我们集中来看一个完整的自定义布局的项目范例。


相关章节:创建自定义布局,自定义布局:一个实例。


Prerequisites(先决条件)

Before reading this document, you should have a solid understanding of the role views play in iOS apps. If you are new to iOS programming and not familiar with the iOS view architecture, read View Programming Guide for iOS before reading this book.

在阅读这篇文档之前,你应该对视图在IOS中扮演一个怎样的角色有一个深刻的理解。如果你是一个IOS编程新手同时不了解IOS中视图的结构,请在阅读本书之前读《IOS 视图编程指南》。


See Also(另见)

Collection views are somewhat related to table views, in that both present ordered data to the user. The implementation of a table view is similar to that of a standard collection view (one which uses the provided flow layout) in its use of index paths, cells, and view recycling. However, the visual presentation of table views is geared around a single-column layout, whereas collection views can support many different layouts. For more information about table views, seeTable View Programming Guide for iOS.

集合视图和表示图有些关系,他们都是展示有序的用户数据。实现一个表示图和实现一个标准的集合视图(使用流动布局提供的)在indexPaths,cell,和视图复用上非常类似。尽管如此,tableView的展现形式是单列布局,而集合视图支持多种布局。更多信息参见《IOS表视图编程指南》

本文原创,转载请注明出处:http://blog.csdn.net/zhenggaoxing/article/details/44082725









IOS 集合视图指南1:介绍

标签:uicollection   官方文档   

原文地址:http://blog.csdn.net/zhenggaoxing/article/details/44082725

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!