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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:41:17+00:00 2026-05-20T14:41:17+00:00

I have a UIView with a grouped UITableView and I’d like the UIView to

  • 0

I have a UIView with a grouped UITableView and I’d like the UIView to stay as a fixed tableHeaderView, rather than moving when scrolling the UITableViewCell‘s. Therefore I’d like the cells to be behind the UIView when scrolling.

This is the code I’m currently using to add my UIView to my UIViewController:

Interface.h:

@interface MyAccountVC : UIViewController <UITableViewDelegate, UITableViewDataSource> {
    HeaderView *myHeaderView; // Inherits from UIView
    UITableView *tv;
}

@property (nonatomic, retain) IBOutlet UITableView *tv;
@property (nonatomic, retain) HeaderView myHeaderView;

Implementation.m (in viewDidLoad):

// Set up the table's header view based on our UIView 'HeaderView' outlet.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"HeaderView" owner:nil options:nil];

for (id currentObject in topLevelObjects) {
    if ([currentObject isKindOfClass:[UIView class]]) {
        self.myHeaderView = (HeaderView *)currentObject;
        break;
    }
}

CGRect newFrame = CGRectMake(0.0, 0.0, self.tv.bounds.size.width, self.myHeaderView.frame.size.height);
self.myHeaderView.frame = newFrame;

self.tv.tableHeaderView = self.myHeaderView;

Not sure if this is the best way of adding myHeaderView to the UITableView, but it seems to be working fine and I can simply add the above code to any UIViewController with a UITableView to re-use the header if need be.

At the moment the header moves with the cells as I scroll, but I’d like the header to be fixed just below the top UINavigationBar while the cells move freely and behind the header. Please let me know if this all makes sense or whether you need more code in order to determine what I am trying to achieve.

  • 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-20T14:41:18+00:00Added an answer on May 20, 2026 at 2:41 pm

    Just elaborating on Paramasivan’s answer.

    I don’t create views with nib files, so I will describe the code assuming you create views programmatically.

    What you need to do is, just place header view at the top, and place a sized tableview below top.

    Example:

    - (void) loadView {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
        self.view = view;
    
        self.myHeaderView = ... // use your init function, with rect something like (0,0,320,50)
        [view addsubview:self.myHeaderView];
    
        self.tv = [[UITableView alloc] init... // with frame like (0,50,320,430)
        [view addSubview:self.tv];
    
        // release everything
    }
    

    This way, you have a UIView that’s always at the top of the view, and won’t scroll with tableview.

    If you add myHeaderView to be the tableview headerView, it will always scroll with the tableview I think.

    In your example, using nib, you can probably resize the frame in the “viewDidLoad” function so that UITableView starts at position (0, myHeaderView.frame.size.height).

    EDIT* finally figured out how to use 4 spaces for code formatting 🙂

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

Sidebar

Related Questions

I have a UIView (created in IB) with a grouped UITableView as a subview.
I have a UIView whose layers will have sublayers. I'd like to assign delegates
I have an iPhone app containing a UITableView in grouped style. In the ViewController
I have a UITableView that is styled as a grouped tableView. Under certain circumstances
I have a UIView that I am setting as the property of a UITableView
I have a UItableView (grouped style). I wanted to customize it so that it
I´m trying to achieve a grouped styled UITableView like the Contact apps detailedView. I
I have UIView designed in IB, and UITableView on it. In view contoller's viewDidLoad
How to make UITableView like above image? I know this is grouped table type.
I have a UIView with a UITableView for a subview. The UIView has an

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.