Four components of a collection view:
Cell: It is a cell in the collection view.
Section: It is a row of data in a collection view, consisting of multiple cells
Supplemental View: It is the head and feet of a section
Decorative view: A background image in a collection view.
Uicollectionview inherits from Uiscrollview. There are two protocols: Uicollectionviewdelegate Trust protocol and Uicollectionviewdatasource data source protocol.
Uicollectionviewcell is a cell class, and its layout is defined by the Uicollectionviewlayout class, which is an abstract class. The Uicollectionviewflowlayout class is a subclass of the Uicollectionviewlayout class. For complex layouts, you can customize the Uicollectionviewlayout class. The Uicollectionview for the controller is the Uicollectionviewcontroller class.
There are four methods in the Uicollectionviewdatasource:
-(Nsinteger) CollectionView: (Uicollectionview *) CollectionView numberofitemsinsection: (NSInteger) Section; Provide the number of columns in a section
-(Uicollectionviewcell *) CollectionView: (Uicollectionview *) CollectionView Cellforitematindexpath: (NSIndexPath *) Indexpath; provide display data for a cell
-(Nsinteger) Numberofsectionsincollectionview: (Uicollectionview *) CollectionView; provides the number of sections in a view
-(Uicollectionreusableview *) CollectionView: (Uicollectionview *) CollectionView Viewforsupplementaryelementofkind :(NSString *) kind Atindexpath: (Nsindexpath *) Indexpath; I supplemental view provides display data
The more important methods in Uicollectionviewdelegate are:
-(void) CollectionView: (Uicollectionview *) CollectionView Didselectitematindexpath: (Nsindexpath *) IndexPath; Trigger after selecting a cell
-(void) CollectionView: (Uicollectionview *) CollectionView Diddeselectitematindexpath: (Nsindexpath *) IndexPath; Triggers after the cell is not selected.
Collection View (Uicollectionview)