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

  • Home
  • SEARCH
  • 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 8799651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:22:51+00:00 2026-06-14T00:22:51+00:00

I have 2 sections in my UITableView. I’d like my first header to be

  • 0

I have 2 sections in my UITableView. I’d like my first header to be nonexistant, no space, no nothing. The first cell touches the top of the screen. I’d like a custom section header for my second section.

I can do this if I don’t use - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section but the moment I use this method a blank header view appears in the first section. What am I doing wrong?

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (!section == 0){
        UIView *header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30.0f)];
        UILabel *label = [[UILabel alloc]initWithFrame:[header frame]];
        [label setText:@"Test Header"];
        [header addSubview:label];

        return header;
    }
    else{
        // This apparently causes a header to appear in section 0. 
        // Without this entire method it works fine- but it means I can't customize
        // the header.
        return nil;
    }



}
  • 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-14T00:22:52+00:00Added an answer on June 14, 2026 at 12:22 am

    Look for the

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

    method of UITableView.

    You can return 0; for the first section.

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

Sidebar

Related Questions

In my 'Sectioned' UITableView I have two sections, the first one for Attributes like
I have a UITableView with 3 sections. The top two sections are static, and
I have a UITableView with each cell being broken into several sections with a
I have 2 sections in a UITableView. I would like to enable the UITableViewCellAccessoryCheckmark
I have design in my application like I have 4 sections in my UITableView
I have four sections in my UITableView, how do I add a header for
I have a setup with sections in a UITableView which all have a custom
I have one problem with two sections in UITableview grouped style. First section having
I have a UITableView With Two Sections. First section has one row and the
I'm trying to get rid of a cached UITableView cell. I have two sections.

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.