iphone - collection view not working when app opens -
i have tab bar app , opening tab contains full screen collection view paging through images. when app opens paging doesn't work of rough , sporadic, however, if change tab , return initial 1 paging works absolutely fine.
has experienced or know causing this?
here code used:
#import "homeviewcontroller.h" @interface homeviewcontroller () @end @implementation homeviewcontroller - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; [self createstonedata]; } - (void)createstonedata { self.homeimages = [nsmutablearray array]; [self.homeimages addobject:[[nsmutabledictionary alloc] initwithobjectsandkeys:@"biddlesdon wardrobes", @"name", @"_np19981-edit.jpg", @"image", nil]]; etc….etc…etc…. [self.collectionview reloaddata]; } - (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { return self.homeimages.count; } - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath{ static nsstring *identifier = @"cell"; uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:identifier forindexpath:indexpath]; uiimageview *homeimageview = (uiimageview *)[cell viewwithtag:100]; homeimageview.image = [uiimage imagenamed:[[self.homeimages objectatindex:indexpath.row] objectforkey:@"image"]]; return cell; } - (void)scrollviewdidscroll:(uiscrollview *)scrollview { if (_startingindexpath) { nsinteger currentindex = floor((scrollview.contentoffset.x - scrollview.bounds.size.width / 1) / scrollview.bounds.size.width) + 1; if (currentindex < [self.homeimages count]) { self.title = self.homeimages[currentindex][@"name"]; } } } - (bool) shouldautorotate { return yes; } -(nsuinteger)supportedinterfaceorientations { return uiinterfaceorientationmaskall; } - (void)willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration { [self.collectionview.collectionviewlayout invalidatelayout]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
Comments
Post a Comment