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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:10:43+00:00 2026-05-27T20:10:43+00:00

I have a view setup in Interface Builder which contains a viewController that loads

  • 0

I have a view setup in Interface Builder which contains a viewController that loads another Nib file. However, for some reason the objects contained in the nib file being loaded never gets called awakeFromNib. What am I missing here? Is there anyway to load views from Nib in interface builder and also manage their properties and sizing in the interface builder?

enter image description here

In general, what are the best practices for managing multiple nibs and composing them into complex views?

Final Solution:

I created a NSViewController subclass like this.

@interface NibLoadingViewController : NSViewController

// The placeholder would be replaced during run-time by the view
@property (weak, nonatomic) IBOutlet NSView *placeholder;

@end

@implementation NibLoadingViewController 

@synthesize placeholder = _placeholder;

- (void)awakeFromNib {
    if (self.placeholder)
        self.view = self.view; // Trigger lazy loading
}

- (void)loadView {
    [super loadView];
    if (!self.view)
        return;
    // Replace the placehoder if it exists
    if (self.placeholder) {
        // Copy over relevant attributes
        self.view.frame = self.placeholder.frame;
        self.view.autoresizingMask = self.placeholder.autoresizingMask;
        self.view.autoresizesSubviews = self.placeholder.autoresizesSubviews;
        // Replaces the old view
        [self.placeholder.superview replaceSubview:self.placeholder with:self.view];
        self.placeholder = nil;
    }
    self.nextResponder = self.view.nextResponder;
    self.view.nextResponder = self;
}

@end

This way, you just need to hook the placeholder outlet in the nib that contains the view controller and it will automatically load the other nibs for you and copy all the attributes from placeholder over and replace it in the main nib.

  • 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-27T20:10:44+00:00Added an answer on May 27, 2026 at 8:10 pm

    The content of the nib-file is lazy-loaded. If you want -(void)awakeFromNib to be called, you need to access something from the nib-file first.

    NSViewController *controller = [[NSViewController alloc] initWithNibName:@"MyView" bundle:nil];
    
    /*
     * awakeFromNib was not called yet
     */
    
    NSView *view = controller.view;
    
    /*
     * but now -(void)awakeFromNib was called.
     */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view using a master page that contains some javascript that needs
I'm not sure what's wrong with the following setup. I have a View that
I have a custom UITableViewCell which I created in Interface Builder. I am successfully
I have setup tab bar controller using interface builder, and each tab bar item
I have a XIB in interface builder that is in Portrait mode and has
I have a UITextView which I create in Interface Builder for an iOS app.
In interface builder I have created a UIVIew (the view of a UIViewController) containing
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
I have a UIImagePickerController as one view in a TabBar setup. Is it possible
I have the following setup, and the empty view text doesn't show up... protected

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.