ios - UICollectionViewCells not appearing in a UICollectionView -
as title suggests have uicollectionview
hooked uiviewcontroller
through ib. have uicollectionview
subclass called imagecell
. in viewcontroller viewdidload
method, register class this:
cgrect collectionviewrect = cgrectmake(384, 60, 728, 924); uicollectionviewflowlayout *flow = [[uicollectionviewflowlayout alloc] init]; imagecollectionview = [[uicollectionview alloc] initwithframe:collectionviewrect collectionviewlayout:flow]; [imagecollectionview registerclass:[imagecell class] forcellwithreuseidentifier:@"cell"]; imagecollectionview.delegate = self; imagecollectionview.datasource = self;
i call method called getphotos
in viewdidappear
(for ui reasons) gets photos service , call [imagccollectionview reloaddata];
inside getphotos
.
then in cellforitematindexpath
following:
imagecell *cell = [collectionview dequeuereusablecellwithreuseidentifier:@"cell" forindexpath:indexpath]; grkalbum *album = [albums objectatindex:indexpath.item]; cell.titlelabel.text = album.name; return cell;
i know not doing wrong here because method being called , cell
not nil
, neither album
.
so, when run of code, uicollectionview
appears, nothing in it. can see background color of collectionview
. @ appreciated.
note: did not create xib imagecell
class when made , using storyboards.
there ways debug situation.
register uicollectionviewcell class instead of customcell , set cell's background color in
cellforitem...
if cells appearing in step 1 try use own cell class , set background
are using storyboard? then..
you dont have register cell collection view. can use prototype cell, give proper id cell.you can design in prototype cell. custom class may not needed in cases.
Comments
Post a Comment