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];
}
하지만 답변을 어떤 식 으로든 감사에서이 줄을 제거합니다. –