UICollectionView用起来比UITableView麻烦多了,如何解决多组头部视图复用时出现的错乱问题就很关键
头部视图有几种样式就注册几种头部视图
// 防止cell和头部视图复用出现错乱
[collectionView registerClass:[WOCOHomeSelectTypeCell class] forCellWithReuseIdentifier:@"selectTypeCell"];
[collectionView registerClass:[WOCOHomeDisplayCell class] forCellWithReuseIdentifier:@"displayCell"];
[collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerSelectType"];
[collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerDisplay"];
头部视图的代理方法中所做的判断处理
// 返回每一组的头部或尾部视图
- (UICollectionReusableView *)collectionView:(UICollectionView *)coll