ios - How to add CollectionView to ViewController with storyboard? -
i have moved collectionview viewcontroller
, created iboutlet, established connection datasource
, delegate
, added protocols: uicollectionviewdatasource
, uicollectionviewdelegate
, uicollectionviewdelegateflowlayout
, , added methods:
- (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection: (nsinteger)section { return 5; } - (nsinteger)numberofsectionsincollectionview:(uicollectionview *)collectionview { return 1; } - (adimagecell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { adimagecell *cell = (adimagecell *)[collectionview dequeuereusablecellwithreuseidentifier:@"adimagecellidentifier" forindexpath:indexpath]; cell.imageview1.image = [uiimage imagenamed:@"3.jpg"]; return cell; }
i created custom cell , add viewdidload
:
[self.collectionview registernib:[uinib nibwithnibname:@"adimagecell" bundle:[nsbundle mainbundle]] forcellwithreuseidentifier:@"adimagecellidentifier"];
but problem here numberofitemsinsection
, numberofsectionsincollectionview
called, not cellforitematindexpath
. why?
sometimes work if remove collectionview registerclass:forcellwithreuseidentifier
viewdidload
method.
collectionview:cellforitematindexpath: never gets called
hope you..
Comments
Post a Comment