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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:18:21+00:00 2026-05-24T17:18:21+00:00

EDIT: After messing with this for days the real questions I have are the

  • 0

EDIT:
After messing with this for days the real questions I have are the following:
1. Does UITableView take up the entire view?
2. If so, how does it set the bounds of the cells to that it looks like it only takes up part of the view.
3. How do I get the bounds of the cells – or more accurately how do I know the bounds of the visible area that the cells are taking up. self.tableView.bounds.size.width does not help because it returns the width of the view.
Thanks.
Leaving the previous info below in case it helps make my question clearer.

Can this be possible?
I have read the apple docs and trolled the forums here and elsewhere and can’t find and answer to this.
Does the footer in a UITableVIew actually take up the entire view no matter what you do? Does it not have a concept of the table width?

Example:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
    [footerView setBackgroundColor:[UIColor redColor]];

    return footerView;
}

This code will create a red line from one edge to the other. No matter what boundaries you give it the line will take up the entire view. The problem with this is that if you want to center a label in that footer you don’t have any way to know where center is if you are supporting orientation changes.
For instance in an iPad app I am trying to do the following:

if ([footerText length] > 0) {
    UIView *customView = [[[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 0, 0.0)] autorelease];

    [customView setBackgroundColor:[UIColor grayColor]];

    UILabel *footerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    footerLabel.numberOfLines = 2;
    footerLabel.adjustsFontSizeToFitWidth = NO;
    [footerLabel setTextAlignment:UITextAlignmentCenter];
    [footerLabel setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5]];
    [footerLabel setOpaque:NO];
    [footerLabel setTextColor:[UIColor whiteColor]];
    [footerLabel setShadowColor:[UIColor lightGrayColor]];
    [footerLabel setFont:[UIFont boldSystemFontOfSize:14]];
    [footerLabel setFrame:CGRectMake(customView.center.x/0.3, 0.0, 600, 40.0)];
    [footerLabel setText:footerText];
    [customView addSubview:footerLabel];
    [footerLabel release];

    NSLog(@"customView width = %f", customView.frame.size.width);
    NSLog(@"tableview width = %f", self.tableView.frame.size.width);
    NSLog(@"tableview center = %f", self.tableView.center.x);

    return customView;
} else {
    return nil;
}

The table’s center in portrait should be 384 (it’s in the detail view/right side) and 351.5 in landscape. But when I use setCenter or try to adjust the left edge based on that center it does not center up.

Final question: How does one center a custom view in a footer with support for orientation when the footer seems to have no concept of the table bounds? I must be missing something in the docs because this has to be a problem solved by someone else but I can’t find it.
Thanks for your time.

  • 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-05-24T17:18:22+00:00Added an answer on May 24, 2026 at 5:18 pm

    To center something within the tableview, you need to wrap it in a container, and set the appropriate autoresize mask for both the embedded view and the container.

    The container should be flexible width, and the embedded view should have both flexible side margins.

    eg:

    - (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {
        static UIView *footerView;
    
        if (footerView != nil)
            return footerView;
    
        NSString *footerText = NSLocalizedString(@"Some Display Text Key", nil);
    
        // set the container width to a known value so that we can center a label in it
        // it will get resized by the tableview since we set autoresizeflags
        float footerWidth = 150.0f;
        float padding = 10.0f; // an arbitrary amount to center the label in the container
    
        footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, footerWidth, 44.0f)];
        footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    
        // create the label centered in the container, then set the appropriate autoresize mask
        UILabel *footerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(padding, 0, footerWidth - 2.0f * padding, 44.0f)] autorelease];
        footerLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
        footerLabel.textAlignment = UITextAlignmentCenter;
        footerLabel.text = footerText;
    
        [footerView addSubview:footerLabel];
    
        return footerView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: Somehow I knew, after two days messing with this, that I'd figure it
FINAL EDIT: After following the answer from Darin Dimitrov, I have found that the
does anyone know what this is not working? i have been trying for days
I'm trying to immediately set a row to Edit mode after it is created.
EDIT: a few weeks after I posted this question Evan Coury wrote an excellent
EDIT: This post was originally specific to ASP.NET, but after thinking about it I'm
[EDIT] I am changing this to more concisely explain what my problem was, after
I have tried a lot on this code but it keeps messing up. The
Alright, I have been messing with this for a few hours now, and I
Edit note: After a seemingly enourmous amount of bad feedback MS got from their

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.