I. Collection view (Uicollectionview)
1. Concept of the collection view
2. How to create
3. Layout of the collection view Uicollectionviewflowlayout
4. Custom cell and Layout protocol Uicollectionviewdelegateflowlayout
The cell is typically customized when used, and proxies are used in the layout.
Uicollectionview's basic Usage example code analysis:
#import "ViewController.h"#import "CollectionReusableView.h"@interfaceViewcontroller () <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>@property (nonatomic,strong) Uicollectionview*CollectionView;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; [Self loadcollectionview]; //Registration Method Creation Uicollectionview[Self.collectionview Registerclass:[uicollectionviewcellclass] Forcellwithreuseidentifier:@"CELL"]; }-(void) loadcollectionview{//Layout class controls the style of each itemUicollectionviewflowlayout *flowlayout =[[Uicollectionviewflowlayout alloc] init]; Flowlayout.itemsize= Cgsizemake ( -, -); //change the size of the upper and lower rows (default is ten)Flowlayout.minimumlinespacing = -; //set the middle size of the two item (default is ten)Flowlayout.minimuminteritemspacing =37.5; //Control Example screen distance up left lower right//flowlayout.sectioninset = uiedgeinsetsmake (100, 100, 100, 0); //Transverse slide//flowlayout.scrolldirection = uicollectionviewscrolldirectionhorizontal;Self.collectionview=[[Uicollectionview alloc]initwithframe:self.view.frame collectionviewlayout:flowlayout]; //Background ColorSelf.collectionView.backgroundColor =[Uicolor Whitecolor]; Self.collectionview.Delegate=Self ; Self.collectionView.dataSource=Self ; [Self.view AddSubview:self.collectionView]; //registering Haeder and Footer methods//Register a Headerview for CollectionView[Self.collectionview Registerclass:[collectionreusableviewclass] Forsupplementaryviewofkind:uicollectionelementkindsectionheader Withreuseidentifier:@"Header"]; //Register a Footerview for CollectionView[Self.collectionview Registerclass:[uicollectionreusableviewclass] Forsupplementaryviewofkind:uicollectionelementkindsectionfooter Withreuseidentifier:@"Footer"]; }//return header and footer settings header and footer-(Uicollectionreusableview *) CollectionView: (Uicollectionview *) CollectionView Viewforsupplementaryelementofkind :(NSString *) kind Atindexpath: (Nsindexpath *) indexpath{if([Kind Isequaltostring:uicollectionelementkindsectionheader]) {Uicollectionreusableview*header = [CollectionView dequeuereusablesupplementaryviewofkind:uicollectionelementkindsectionheader Withreuseidentifier:@"Header"Forindexpath:indexpath]; returnheader; } Else{Uicollectionreusableview*footer = [CollectionView dequeuereusablesupplementaryviewofkind:uicollectionelementkindsectionfooter Withreuseidentifier:@"Footer"Forindexpath:indexpath]; returnfooter; } }//sets the size of the footer and header of the CollectionView-------the Uicollectionviewdelegateflowlayout proxy method----------//set the size of the CollectionView footer-(Cgsize) CollectionView: (Uicollectionview *) CollectionView layout: (Uicollectionviewlayout *) collectionviewlayout referencesizeforfooterinsection: (nsinteger) section{returnCgsizemake ( -, -);}//set the header size of the CollectionView-(Cgsize) CollectionView: (Uicollectionview *) CollectionView layout: (Uicollectionviewlayout *) collectionviewlayout referencesizeforheaderinsection: (nsinteger) section{returnCgsizemake ( -, -);}//the two proxy methods that you need to implement when you create a uicollectionview------------------------------------(Nsinteger) CollectionView: (Uicollectionview *) CollectionView numberofitemsinsection: (nsinteger) section{return -;}-(Uicollectionviewcell *) CollectionView: (Uicollectionview *) CollectionView Cellforitematindexpath: (NSIndexPath *) indexpath{//Uicollectionviewcell does not carry the control itself, it is a blank//so, in the project, we usually customize a UicollectionviewcellUicollectionviewcell *cell = [CollectionView dequeuereusablecellwithreuseidentifier:@"CELL"Forindexpath:indexpath]; //Set Background colorCell.backgroundcolor =[Uicolor Redcolor]; returncell;}
Two. Notification Center (Nsnotificationcenter)
21st Lecture. Uicollectionview (collection View) and waterfall flow effect, Notification Center (nsnotificationcenter).