Collection View (Uicollectionview)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.