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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:10:59+00:00 2026-06-09T13:10:59+00:00

How do I change the width of a table view header?? I have a

  • 0

How do I change the width of a table view header??

I have a UITableView, and a header which is a UIImageView set in ViewForHeaderInSection.

When I run the app the header stretches to the width of the screen, while the rows (also images) are the width I want.

The height seems to be ok, it’s just the width that’s the problem.

When I create the Image to set as the header I make a frame for it, but it doesn’t do anything.

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

UIImage *tableHeaderImage = [UIImage imageNamed:@"tableTop"];
UIImageView *headerImageView = [[[UIImageView alloc] initWithImage:tableHeaderImage] autorelease];

headerImageView.frame = CGRectMake(0,0,277,7);
NSLog(@"%@",headerImageView.frame.size.width);    

return headerImageView;
}

p.s. it is all programmatically coded.

  • 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-09T13:11:00+00:00Added an answer on June 9, 2026 at 1:11 pm

    You need to return a UIView. Once you have set one up add the image view as a subview and return the view:

    - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.frame), 7);
        UIImage *tableHeaderImage = [UIImage imageNamed:@"tableTop"];
        UIImageView *headerImageView = [[[UIImageView alloc] initWithImage:tableHeaderImage] autorelease];
    
        headerImageView.frame = CGRectMake(0,0,277,7);
        [view addSubview headerImageView];
        return view;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a table view and in its header I have set a
I'd like to animate table body TBody change with jQuery. I have a table:
How to change the width/height if I have the following code and using php:
how do you change the width of a textbox in an asp.net-mvc View i
I am trying to create a table view header with rounded corners but a
I have a setup with sections in a UITableView which all have a custom
I have the following markup as a part of a Razor view: <table> <caption>Presidents</caption>
I have a dynamically generated table in my page, which was generated by a
UPDATED : Scroll down for updated. I have a UITableView which cells contain few
I would like to set the bounds for my table view (in a UITableViewController)

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.