user3551029 user3551029 - 1 month ago 13
iOS Question

Action for header in UICollectionView IOS

I have different number of headers in a collection in my code and when I click a header each header has different actions. If I select a cell,

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
method is called. So, is there any delegate method which is called when any supplementary view is selected?

Answer

try to add a guesture to your view such as

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
                               initWithTarget:self
                               action:@selector(handleTapGuesture)];

[headerView addGestureRecognizer:tap];

Place this code where you setUp your HeaderView

and then implement the -(void)handleTapGuesture; method to carry out your actions

Comments