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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:13:03+00:00 2026-05-14T15:13:03+00:00

.Hi, I have a nib file that contains an header that will be used

  • 0

.Hi,

I have a nib file that contains an header that will be used in most of my views, so that I can change it’s layout just once when I need. I’d like to know if it’s possible to add the header nib view with interface builder, or if I need to do that programmatically and how should it be done.

I’ve thought about setting the subclass of the subview to a UIView subclass that automatically loads the nib file.

- (id)initWithFrame:(CGRect)frame {

    UIView *cell;

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed: @"MainHeaderView"
                                                 owner: self
                                               options: nil];

    for (id oneObject in nib) 
        if ([oneObject isKindOfClass: [UIView class]]) 
            cell = (UIView *) oneObject;

    if ((self = [super initWithFrame: [cell frame]])) {
        // Initialization code
    }
    return self;
}

But this also doesn’t seem to work.

  • 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-14T15:13:04+00:00Added an answer on May 14, 2026 at 3:13 pm

    Ok, I’ve solved this another way.

    I’ve created the headerView and the controller, and a subclass of UIViewController for all views that needed the header to be displayed, loading them all with the header. Something like this:

    @implementation MyDefaultViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        MyTestAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
        [self.view addSubview: [appDelegate.headerViewController view]];
    }
    

    Every view that needs the header to be there will have a controller that’s a subclass of MyDefaultViewController. Seems to work, although the fact that I don’t specify where to place the header scares me a bit xD

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

Sidebar

Related Questions

I have a UIViewController subclass that used to have an associated nib file. I've
I have a nib file where I have a view that contains a background
I have a second .nib file that is a localized version of the main
I have a window contained in a nib file that gets loaded by a
I have a ViewController that includes its own .nib file, I am wanting to
I have a custom NSWindowController subclass that loads a NIB file during initialization like
I have a nib (winA.xib) that contains a window. My app delegate contains an
I have a UIView control in the nib file that I am working on.
I have a UITableView tableHeaderView defined in a nib file. The tableHeaderView contains a
I'm trying to create a nib that contains a view that will be embedded

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.