Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
1
I have a weird problem with collectionView. I load collectionView in this way.
Code:
- (void)viewDidLoad { 
    [super viewDidLoad];
    self.achievements = [self createAchievementsObjects];
    [self.achievementsCollectionView reloadData];
}
and those are the delegate methods

Code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    AchievementCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"achievementCell" forIndexPath:indexPath];
    [cell setUpTheCellWithAchievement:self.achievements[indexPath.row]];
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.achievements.count;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 10;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    NSInteger width = (self.view.frame.size.width - 40 ) / 3;
    return CGSizeMake(width, width);
}
it displays only 15 cells and when i scroll down notihg is shown. What is wrong here ?
 

MarkCollette

macrumors 68000
Mar 6, 2003
1,559
36
Toronto, Canada
If you put breakpoints or NSLog statements in collectionView:layout:sizeForItemAtIndexPath and collectionView:cellForItemAtIndexPath where you inspect all of the values you're using, what do you see?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.