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.

手势操作可以使用在单元格和布局操作中

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

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.

Relevant chapters: Creating
Custom Layouts
Custom
Layouts: A Worked Example

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

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

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

时间: 2024-10-11 16:56:07

IOS 集合视图指南1:介绍的相关文章

IOS 集合视图指南2:集合视图基础

Collection View Basics(集合视图基础) To present its content onscreen, a collection view cooperates with many different objects. Some objects are custom and must be provided by your app. For example, your app must provide a data source object that tells the

(译)IOS block编程指南 1 介绍

Introduction(介绍) Block objects are a C-level syntactic and runtime feature. They are similar to standard C functions, but in addition to executable code they may also contain variable bindings to automatic (stack) or managed (heap) memory. A block ca

iOS集合视图单元格高亮和选中的区别

大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 免责申明:本博客提供的所有翻译文章原稿均来自互联网,仅供学习交流之用,请勿进行商业用途.同时,转载时不要移除本申明. 如产生任何纠纷,均与本博客所有人.发表该翻译稿之人无任何关系.谢谢合作! 集合视图(Collection View)拥有一个遵守UICollectionViewDelegate协议的delegate属性.该委托属性将从集合视图接收到各种委托调用

IOS block编程指南 1 介绍

Introduction(介绍) Block objects are a C-level syntactic and runtime feature. They are similar to standard C functions, but in addition to executable code they may also contain variable bindings to automatic (stack) or managed (heap) memory. A block ca

集合视图控制器(CollectionViewController) 、 标签控制器(TabBarController) 、 高级控件介绍

  1 创建集合视图,设置相关属性以满足要求 1.1 问题 集合视图控制器UIConllectionViewController是一个展示大量数据的控制器,系统默认管理着一个集合视图UICollectionView,功能几乎和UITableViewController差不多,能够以多行多列的形式展示数据. 集合视图UICollectionView继承至UIScrollView,也同tableView一样有两个协议,分别是UICollectionViewDataSource数据源协议和UIColl

ios学习记录 day42 UI18 集合视图

集合视图UICollectionView 简单来说就是多列的TableView 它们同样是datasource和delegate设计模式UICollectionViewLayout是一个对View布局和行为描述的类  UICollectionViewFlowLayout是它的子类 ios学习记录 day42 UI18 集合视图,码迷,mamicode.com

iOS基础之CollectionView(集合视图)

在iOS6.0之后,苹果推出了?个新的继承于UIScrolleriew的一个视 图,UICollectionView,也被称之为集合视图.和UITableView共同作为 在开发中常常用的两个视图,常常作为项目的主界面出现. 代码演示: #import "YourCollectionViewCell.h" @implementation YourCollectionViewCell -(instancetype)initWithFrame:(CGRect)frame{ self = [

iOS 8开发指南

这篇是计算机类的优质预售推荐>>>><iOS 8开发指南(第2版)> 国内第一本iOS8开发的原创图书全新改版 objective-c和swift双语讲解 全部实例视频 涵盖WatchKit HealthKit HomeKit三大热门框架 内容简介 本书共35章,循序渐进地讲解了iOS 8应用开发的基本知识.本书从搭建开发环境讲起,依次讲解了Objective-C语言基础.Swift语言基础.Cocoa Touch.Xcode Interface Builder界面开发

线程同步-iOS多线程编程指南(四)-08-多线程

首页 编程指南 Grand Central Dispatch 基本概念 多核心的性能 Dispatch Sources 完结 外传:dispatch_once(上) Block非官方编程指南 基础 内存管理 揭开神秘面纱(上) 揭开神秘面纱(下) iOS多线程编程指南 关于多线程编程 线程管理 Run Loop 线程同步 附录 Core Animation编程指南 Core Animation简介 基本概念 渲染架构 几何变换 查看目录 中文手册/API ASIHTTPRequest Openg