我想返回一个部分的标题,但不是另一个部分。
我该怎么回事?
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == RDSectionRecipeDetail) {
/*create view here*/
return myView
}else{
//What to return when I dont want a view?
return ?;
}
}
答案 0 :(得分:1)
这是我目前的做法
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *headerView = nil;
headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"collectionHeader" forIndexPath:indexPath];
if (kind == UICollectionElementKindSectionHeader && indexPath.section != 0) {
headerView.hidden = YES;
}
else{
headerView.hidden = NO;
}
return headerView;
}