Skip to content

如果实现了代理方法返回头部脚部视图,如果我只返回头部 脚部返回nil会直接崩溃 #9

Description

@zhangxiongwen

//返回头脚视图

  • (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
    // CollectionHeaderAndFooterView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"sectionHeader" forIndexPath:indexPath];
    // headerView.titleLabel.text = @"头视图";
    // headerView.titleLabel.backgroundColor = [UIColor orangeColor];
    // return headerView;
    return nil;

    }else{
    CollectionHeaderAndFooterView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"sectionFooter" forIndexPath:indexPath];
    footerView.titleLabel.text = @"脚视图";
    footerView.titleLabel.backgroundColor = [UIColor cyanColor];
    return footerView;

    }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions