Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:48:48+00:00 2026-06-12T11:48:48+00:00

I know that a table view header(the most top-part of a table view) is

  • 0

I know that a “table view header”(the most top-part of a table view) is a View
So I try to add a UITapGestureRecognizer to it ,but it doesn’t work…

code is simple :

- (void)tap:(UITapGestureRecognizer *)recognizer
{
    // do something
}

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc]    initWithTarget:self action:@selector(tap:)];
[self.tableView.tableHeaderView addGestureRecognizer:recognizer];

Any tips here to care ? thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:48:49+00:00Added an answer on June 12, 2026 at 11:48 am

    Here’s the thing that works for me:
    Instead adding this:

    self.tableView.tableHeaderView
    

    I add gesture recognizer on every UILabel on tableview.

        -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
    
        UILabel *headerLabel = [[UILabel alloc]init];
        headerLabel.tag = section;
        headerLabel.userInteractionEnabled = YES;
        headerLabel.backgroundColor = [UIColor greenColor];
        headerLabel.text = [NSString stringWithFormat:@"Header No.%d",section];
        headerLabel.frame = CGRectMake(0, 0, tableView.tableHeaderView.frame.size.width, tableView.tableHeaderView.frame.size.height);
    
    
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(catchHeaderGesture:)];
        tapGesture.cancelsTouchesInView = NO;
        [headerLabel addGestureRecognizer:tapGesture];
    
        return headerLabel;
    
        //return nil;
    }
    
    -(void)catchHeaderGesture:(UIGestureRecognizer*)sender
    {
        UILabel *caughtLabel = (UILabel*)sender.view;
    
        NSLog(@"header no : %d", caughtLabel.tag);
    }
    

    I hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a table view header with rounded corners but a
I know that table sources need a data source to hold the data that
We all know that a hash table has O(1) time for both inserts and
I know that I should have schema of a table before calling NewRow method
I have a table that i want to highlight during onmouseover/onmouseout. I already know
I have 2 tables. How do I know IDs that are in one table
I know that in standard SQL you can do this: update top (100) table1
Apple's documentation on UITableView discusses how to add/edit/delete rows, but it doesn't discuss adding/editing/deleting
i know that this is basic objective C question but I have serious problems.
I am having table view in my iPhone application. The requirement is that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.