Copyright NOTICE: This article is the original article, without the owner's permission to reprint.
Directory (?) [+]
First, meet Uicollectionview . [OBJC] view plain copy Ns_class_available_ios (6_0) @interface Uicollectionview:uiscrollview
The Uicollectionview and Uicollectionviewcontroller classes are iOS6 newly introduced APIs for displaying collection views, more flexible layouts, and multiple-column layouts, similar to UITableView and Uitableviewcontroller class.
Using Uicollectionview must implement Uicollectionviewdatasource,uicollectionviewdelegate, Uicollectionviewdelegateflowlayout these three agreements.
here are some common methods, specific use can refer to Demo: point I download the Apple official demo: Click I download [OBJC] View Plain copy - (void) viewdidload { [super viewDidLoad]; self.title = @ "Uicollectionview learning"; //generates a cell via nib, then registers nib view needs to inherit uicollectionviewcell [self.collectionView registerNib:[UINib nibwithnibname:@ "Sqcollectioncell" bundle:nil] forCellWithReuseIdentifier:kcellIdentifier]; //Registration headerview NIB's view needs to inherit uicollectionreusableview [self.collectionview registernib: [uinib nibwithnibname:@ "Sqsupplementaryview" bundle:nil] forsupplementaryviewofkind: uicollectionelementkindsectionheader withreuseidentifier:kheaderidentifier]; //registered Footerview nib's view needs to inherit Uicollectionreusableview [self.collectionView registerNib:[UINib nibwithnibname:@ "Sqsupplementaryview" bundle:nil] forsupplementaryviewofkind: uicollectionelementkindsectionfooter withreuseidentifier:kfooteridentifier]; // self.collectionview.allowsmultipleselection = yes ;//default is no, can I select multiple } - (void) didreceivememorywarning { [super didReceiveMemoryWarning]; // dispose of any resources that can be recreated. } #pragma mark -CollectionView datasource // section - (Nsinteger) Numberofsectionsincollectionview: (uicollectionview *) CollectionView {   &Nbsp; return 2; } //item number - (Nsinteger) CollectionView: ( uicollectionview *) Collectionview numberofitemsinsection: (Nsinteger) section { return 6; }