Tuesday, 15 September 2015

uicollectionview - iOS UICollectionViewController Not showing center cells. But can click on them -



uicollectionview - iOS UICollectionViewController Not showing center cells. But can click on them -

i've created custom uicollectionviewcontroller.

i have 2 albums want display - each have bit different functionality views same (custom cell sizes , etc.). base of operations viewcontroller inheriting 2 customized uicollectionviewcontroller specific behavior seeking.

the inheritance

uicollectionviewcontroller -> galleyviewcontroller (my base of operations class) -> cameraalbumviewcontroller.

uicollectionviewcontroller -> galleyviewcontroller (my base of operations class) -> differentalbumviewcontroller

for reason not seeing center cells on screen, able click on them. i've tried changing size of cells, , see 3 cells, boundaries of cells off (i can select between cells , getting delegate methods called)

thinking maybe inheritance wrong (perhaps missing in base of operations class) created new project basic utilize of uicollectionviewcontroller , followed several tutorials.

still not seeing center cells

from believe perhaps in storyboard incorrect.

my code this:

#import "mycollectionviewcontroller.h" #import <assetslibrary/assetslibrary.h> @interface collectionviewcell : uicollectionviewcell // customized cell @property (nonatomic,strong) uiimageview *imageview; @end @implementation collectionviewcell @synthesize imageview; -(id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { self.imageview = [[uiimageview alloc] initwithframe:frame]; [self.contentview addsubview:self.imageview]; } homecoming self; } @end @interface mycollectionviewcontroller () // collection view controller @property (nonatomic,strong) nsmutablearray *photos; @property (nonatomic,strong) alassetslibrary *defaultlibrary; @end @implementation mycollectionviewcontroller @synthesize photos,defaultlibrary; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } homecoming self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. [self.collectionview registerclass:[collectionviewcell class] forcellwithreuseidentifier:@"cell"]; [self initassets]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } -(void)initassets { self.photos = [nsmutablearray new]; [self.photos removeallobjects]; self.defaultlibrary = [[alassetslibrary alloc] init]; [self.defaultlibrary enumerategroupswithtypes:alassetsgroupsavedphotos usingblock:^(alassetsgroup *group, bool *stop) { [group enumerateassetsusingblock:^(alasset *asset, nsuinteger index, bool *stop) { if (asset) { [self.photos addobject:asset]; } }]; if (group == nil) { [self.collectionview reloaddata]; } } failureblock:^(nserror *error) { nslog(@"error"); }]; } #pragma mark - #pragma mark collectionviewdelegates -(nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { homecoming self.photos.count; } -(nsinteger)numberofsectionsincollectionview:(uicollectionview *)collectionview { homecoming 1; } -(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { collectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:@"cell" forindexpath:indexpath]; alasset *asset = [self.photos objectatindex:indexpath.row]; uiimage *im = [uiimage imagewithcgimage:[asset thumbnail]]; cell.imageview.image = im; homecoming cell; } -(cgsize)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout *)collectionviewlayout sizeforitematindexpath:(nsindexpath *)indexpath { homecoming cgsizemake(100, 100); } @end

some screenshots of story board, photographic camera album simulator

uicollectionview uicollectionviewcell uicollectionviewlayout

No comments:

Post a Comment