In a UICollectionView, the cells will not sit on the bottom

后端 未结 2 632
青春惊慌失措
青春惊慌失措 2020-12-19 19:54

Note it turned out it was a simple mistake the cells would not \"sit on the bottom\". However, it\'s an interesting question: \"how to move the cells up and

2条回答
  •  佛祖请我去吃肉
    2020-12-19 20:52

    Try this. hopefully, it can help

    -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
        return collectionView.frame.size;
    }
    

    (For future readers, indeed you also typically need the other one ...)

    -(CGSize) collectionView:(UICollectionView *)collectionView
         layout:(UICollectionViewLayout *)collectionViewLayout
         sizeForItemAtIndexPath:(NSIndexPath *)indexPath
        {
        return self.view.frame.size;
        }
    
    -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView
       layout:(UICollectionViewLayout*)collectionViewLayout
       insetForSectionAtIndex:(NSInteger)section
        {
        return UIEdgeInsetsMake(0,0,0,0);   //t,l,b,r
        }
    

提交回复
热议问题