2016-03-05 94 views
1

我有一個空白空間,我無法找到UICollectionView頂部的原因。水平頂部的奇數空白UICollectionView

我禁用了故事板中的標題,所以我不相信那是那個。

這裏有一個畫面:

enter image description here

爲的CollectionView的代碼

- (void)setupCollectionView 
{ 
    [self.scoreCollectionView setDataSource:self]; 
    [self.scoreCollectionView setDelegate:self]; 
    [self.scoreCollectionView registerClass:[AAScoreCell class] forCellWithReuseIdentifier:cellIndentifier]; 
} 

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 
{ 
    return 10; 
} 

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    AAScoreCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIndentifier forIndexPath:indexPath]; 

    if (_selectedIndexPath) { 
    [cell showSelection:[indexPath isEqual:_selectedIndexPath]]; 
    } 

    return cell; 
} 

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    AAScoreCell *cell = (AAScoreCell*)[collectionView cellForItemAtIndexPath:indexPath]; 
    [cell showSelection:![indexPath isEqual:_selectedIndexPath]]; 
    _selectedIndexPath = [indexPath isEqual:_selectedIndexPath] ? nil : indexPath; 
} 

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    AAScoreCell *cell = (AAScoreCell*)[collectionView cellForItemAtIndexPath:indexPath]; 
    [cell showSelection:NO]; 
    _selectedIndexPath = nil; 
} 

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return CGSizeMake(self.scoreCollectionView.frame.size.height-50, self.scoreCollectionView.frame.size.height-50); 
} 

回答

1

不會假裝我明白爲什麼,但:

[self setAutomaticallyAdjustsScrollViewInsets:NO]; 

解決問題的我