나는 내가 가지고있는 세포의 모든 행 후 UICollectionViewController.
UICollectionView 헤더는 모든 행
UITableView
헤더 반복 서브 클래스 해요를 반복합니다. 헤더가 "싱글"이어야하며 항상 탐색 모음과 같은 화면 상단에 있어야합니다.
나는 다음과 같은 코드를 사용하고 있습니다 : 내 UICollectionViewController
클래스 :
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return [categoryArray count]/2;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 2;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CategoryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CategoryCell" forIndexPath:indexPath];
CategoryViewModel *category = [categoryArray objectAtIndex:(indexPath.section*2 + indexPath.row)];
cell.name.text = category.name;
cell.image.image = category.image;
return cell;
}
-(UICollectionReusableView *) collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
if(headerIndexPath == nil){
headerIndexPath = indexPath;
}
CategoryScreenHeader *categoryScreenHeader = [collectionView dequeueReusableSupplementaryViewOfKind:
UICollectionElementKindSectionHeader withReuseIdentifier:@"CategoryScreenHeader" forIndexPath:headerIndexPath];
categoryScreenHeader.headerName.text = @"Some title";
categoryScreenHeader.headerImage.image = [UIImage imageNamed:@"step-0.png"];
return categoryScreenHeader;
}
당신을 감사합니다.
어떤 레이아웃을 사용합니까? – chris
나는 UICollectionViewLayout을 사용하고 있습니다. –