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 8582451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:17:44+00:00 2026-06-11T21:17:44+00:00

I am parsing some strings from server and putting those strings in header of

  • 0

I am parsing some strings from server and putting those strings in header of grouped tables, I have multiple grouped tables on a view.

my regular structure for gropued tableview is

Header:
String1
string2
String3 

TableviewCells
.
.
.

Sometimes one or two of the strings returns null. So that means line is empty but since I declare my height like

-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
    return 90;
} 

I cannot arrange height of the headers dyncamically

How can I reduce the total height of the header if one of the strings is empty?
So rather then this

String1
String2


Tableview

This should happen:

String1
String2

TableViewCells

What I am exactly asking is

if [string3 length]==0 
    set heightForHeaderInSection: 60
else
    set heightForHeaderInSection: 90

My code is:

-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
    return 90;
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection: (NSInteger)section {
      NSString * presenter = [[self agenda] getBriefingPresenter:section];
      NSString * time = [[self agenda] getBriefingTime:section];
     NSString * subject = [[[[self agenda] getMeetingBriefings] objectAtIndex:section] objectForKey:@"subject"];

    UILabel *subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, 0, 484, 23)];
    subjectLabel.textColor = [UIColor colorWithRed:0/256.0 green:84/256.0 blue:129/256.0 alpha:1.0];
    subjectLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:25];
    subjectLabel.text = subject;
    subjectLabel.backgroundColor = [UIColor clearColor];
    [subjectLabel sizeToFit];



    UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, subjectLabel.frame.size.height, 484, 23)];
    timeLabel.textColor = [UIColor colorWithRed:51/256.0 green:51/256.0 blue:51/256.0 alpha:1.0];
    timeLabel.font = [UIFont fontWithName:@"Century Gothic" size:21];
    timeLabel.text = time;
    timeLabel.backgroundColor = [UIColor clearColor];
    [timeLabel sizeToFit];

    // Create label with section title
    UILabel *presenterLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, timeLabel.frame.origin.y + timeLabel.frame.size.height, 484, 23)];
    presenterLabel.textColor = [UIColor colorWithRed:71/256.0 green:71/256.0 blue:71/256.0 alpha:1.0];
    presenterLabel.font = [UIFont fontWithName:@"Century Gothic" size:18];
    presenterLabel.text = presenter;
    presenterLabel.backgroundColor = [UIColor clearColor];
    [presenterLabel sizeToFit];

    // Create header view and add label as a subview
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 320, 400)];


    [view addSubview:subjectLabel];
    [view addSubview:timeLabel];
    [view addSubview:presenterLabel];


    return view;
}
  • 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-11T21:17:45+00:00Added an answer on June 11, 2026 at 9:17 pm

    Here this should work, you can change the height at return value to whatever you want they dont have to be constants

    // set header height of gropued tableview
    -(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
    
        NSString * presenter = [[self agenda] getBriefingPresenter:section];
        NSString * time = [[self agenda] getBriefingTime:section];
        NSString * subject = [[[[self agenda] getMeetingBriefings] objectAtIndex:section] objectForKey:@"subject"];
    
        //possible incoming data scenes
        if ([time length]==0 || [presenter length]==0 || [subject length]==0) {
            return 60;
        }
        else if(([time length]==0 && [presenter length]==0 ) || ([time length]==0 && [subject length]==0 ) || ([presenter length]==0 && [subject length]==0 )){
            return 45;
        }
        else if ([time length]==0 && [presenter length]==0 && [subject length]==0){
            return 30;
        }
        else{
            return 90;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I seem to have a problem passing some strings on from one form to
I have some messages being passed back from my server through php. The problem
I am fetching the some data from the server using XML parsing that is
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() To
I'm currently working with parsing some data from SQL Server and I'm in need
I am parsing some XML that will have a link such as the following
I've got some problems parsing the response of a Last.fm API call from a
I have two JSPs where I am displaying some info from database in a
I am passing some JSON back from client-side to server-side. if (historicalJSONAttributes != null)
I have some WSDL from which I need to generate a web service implementation.

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.