Skip to content

How to set Headerview #4

@PKhunt

Description

@PKhunt

I want to set Headerview in BidirectionalCollectionViewLayout But I am not able to set headerview.

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self.collectionView registerNib:[UINib nibWithNibName:@"DABrandListHeaderView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
}


- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
    
        DABrandListHeaderView *reusableview = (DABrandListHeaderView *)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
    
        [reusableview.titleLabel setText:[[self.itemsArray objectAtIndex:indexPath.section] valueForKey:@"section"]];
    
        return reusableview;
    }

    return nil;
}

I have put this code but this code is not being called. Please help me so I can set header in collection view.

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