返回部分的标题视图,但不返回其他部分

时间:2013-11-07 19:08:34

标签: ios uicollectionview

我想返回一个部分的标题,但不是另一个部分。

我该怎么回事?

-(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 ?;
    }
}

1 个答案:

答案 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;
     }