0
私はUICollectionView
カスタム高さと幅を持っていますが、私はアプリを起動すると、画面に最初に表示されるすべてのセルは、私の与えた高さと幅に関して完全に設定されますが、セル幅。ここでUICollectionViewセル幅の問題
は間隔など、高さと幅を設定するためのメソッドです
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 5.0;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
return 5.0f;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
[self.collectionView setNeedsLayout];
[self.collectionView layoutIfNeeded];
CGFloat width = self.collectionView.frame.size.width;
return CGSizeMake((width/2)-5, 220);
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return [listOfRetailers_ count];
}
-(void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
BDRetailerCollectionViewCell *newCell = (BDRetailerCollectionViewCell*)cell;
UIFont *font = newCell.brandName.font;
[newCell.brandName setFont:[font fontWithSize:12]];
[newCell setNeedsLayout];
[newCell layoutIfNeeded];
}
が、あなたの答えのための任意の方法のおかげで、この行を削除します。 –