0
행/섹션 당 셀을 3 개 표시하고 싶습니다. 내 콘텐츠가 API에서 제공됩니다. 아래의 코드처럼 정적 인 경우 셀 간격 (및 행 간격)이 좋습니다. numberOfSectionsInCollectionView를 사용하지 않을 때 UICollectionView에서 행 간격 설정
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 10;
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
return 3;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionView *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 1.5;
}
내 데이터 API에서오고 있기 때문에
, 나는 한 줄에 3을 표시 itemSize 폭을 설정하고numberOfSectionsInCollectionView
을 주석. 그러나 행당 간격은 큰 차이가 있습니다.
//-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
// return 10;
//}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
return _results.count;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionView *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 1.5;
}
해결 방법이 있습니까? 아니면 이것을 구현하는 더 좋은 방법이 있습니까?