Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGhaz Sabh
5,005 PointsCustomizing a UICollectionViewFlowLayout
I have completed Customizing a UICollectionViewFlowLayout so far without any issue, I have followed every steps, can see the orang bar and white text, but I can't see the boxes for the pics. all i can see is the background is white.
self.collectionView.backgroundColor = [UIColor whiteColor]; } Any help I really appreciate it ghaz,
9 Answers
Thomas Nilsen
14,957 PointsYou don't need to set the backgroundColor, but try to set the color in one of the delegate methods:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
PhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"icon" forIndexPath:indexPath];
cell.backgroundColor = [UIColor lightGrayColor];
cell.photo = self.photos[indexPath.row];
return cell;
}
If you already have done that or it doesn't work, make sure you're returning the number of boxes to be displayed:
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
//Numbers of photos, so return the array count of photos.
return 10;
}
Ghaz Sabh
5,005 PointsHi Thomas, Thank you so much for you're reply, I have tried all the code you sent it didn't work not sure, but still im not getting any error.
Thomas Nilsen
14,957 Pointsdo you mind copy/pasting in what you have so I can take a look? :)
Ghaz Sabh
5,005 Pointsthat the issue I can't see any error they only issue that i can't see the boxes for the photos. I happy to send you my project file.
Thomas Nilsen
14,957 Pointsokay. Send away :)
Ghaz Sabh
5,005 Pointsto what email ? my email is ghazouan@me.com
Thomas Nilsen
14,957 Pointsyou can send your project zipped to -removed since question solved-
Thomas Nilsen
14,957 PointsSorry it took so long, it was hard to spot the error :P
you write
- (NSInteger)collectionview:(UICollectionView *)collectionView numberofItemsInSection:(NSInteger)section{
return 10;
}
When it's supposed to be:
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 10;
}
Do you spot the difference? If not -
you wrote 'collectionview' with small 'v' and 'numberofItemsInSection' with small 'o'
Ghaz Sabh
5,005 PointsI feel so stupid now, thank you so much for you help, I can now move on with ur training.
Thomas Nilsen
14,957 PointsNo problem! ( :