UICollectionView를 처음 사용하기 시작했습니다. 멋지게 작동하지만 문제와 그에 대한 질문이있는 것 같습니다.UICollectionView registerCell - 빈 셀
나는 다음과 같이 내 UICollectionView 설정을 가지고 사용자 정의 셀 :
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section
{
return 10;
}
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView
{
return 1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ContactCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
cell.nameLbl.text = @"text";
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(145, 95);
}
- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(10, 10, 10, 10);
}
그래서이 모든 멋쟁이, 그러나 내가 추가 한이 라인 viewDidLoad
에 :
[collectionView registerClass:[ContactCell class] forCellWithReuseIdentifier:@"Cell"];
이 일으키는 문제입니다 나는 왜 그런지 이해하지 못한다. 이 줄을 활성화하면 모든 셀이 비어있게됩니다. 어째서? 내가 뭘 놓치고 있니?
또한 내가 이해하는 것처럼, 그 라인이 재사용 가능한 셀을 가능하게한다면, 왜 컬렉션 뷰와 테이블 뷰를 가질 필요가 없는가?
기술적 인 도움이나 도움이 될만한 답변이 있으면 감사합니다.
방법은 셀에 대한보기를 설정? 서브 클래스에서 프로그래밍 방식으로? – jackslash
스토리 보드에 설정했습니다. 하나의 셀에 UICollectionView가 있고 그 셀에 식별자, 사용자 정의 클래스가 연결되어 있습니다. –