Protocol
UICollectionViewDelegate
--The UICollectionViewDelegate
protocol defines methods that allow you to manage the selection and highlighting of items in a collection view and to perform actions on those items. The methods of this protocol are all optional.
这个协议里面的所有方法都是可选的,这个协议里面的方法是用来管理items的选中状态、高亮状态以及在这个item上执行动作。
Inherits From
UIScrollViewDelegate
--继承于UIScrollViewDelegate
Declaration --声明
protocol UICollectionViewDelegate
Overview -- 概览
--Many methods of this protocol take NSIndexPath
objects as parameters. To support collection views, UIKit declares a category on NSIndexPath
that enables you to get the represented item index and section index, and to construct new index path objects from item and index values.
这个协议里面的很多方法都是以NSIndexPath
对象作为参数,所以对象里面有一个类别(拓展)是用来获取当前展示的items和section的index的,并且也可以从item上创建新的NSIndexPath
实例
--Because items are located within their sections, you usually must evaluate the section index number before you can identify the item by its index number.
先估算section的index,才可以计算items的index
--When configuring the collection view object, assign your delegate object to its delegate
property. For more information, see UICollectionView
.
在配置collection view对象之前,你要先给collection view的delegate属性赋值
Topics -- 专题
Managing the Selected Cells -- 管理和选择cell
Changing the Appearance of Selected and Highlighted Cells --示例代码,改变cell的选中和高亮状态
--Provide visual feedback to the user about the state of a cell and the transition between states.
cell之间的状态以及状态之间的转换示例